Example: custquery.4gl (function fetch_rel_cust)
This function fetches a customer record in the direction specified by the flag passed as parameter.
Function
fetch_rel_cust
: 1 FUNCTION fetch_rel_cust(p_fetch_flag SMALLINT) RETURNS ()
2 MESSAGE " "
3 IF fetch_cust(p_fetch_flag) THEN
4 CALL display_cust()
5 ELSE
6 IF p_fetch_flag == 1 THEN
7 MESSAGE "End of list"
8 ELSE
9 MESSAGE "Beginning of list"
10 END IF
11 END IF
12 END FUNCTION
Note:
- Line
1
: The parameter passed top_fetch_flag
will be1
or-1
, depending on the direction in which the scroll cursor is to move. The function returns no value. - Line
2
resets the message display to blanks. - Line
3
calls the functionfetch_cust
, passing it the value ofp_fetch_flag
. The functionfetch_cust
returningFALSE
if there was no row found. - Line
4
If a row was found (thefetch_cust
function returnedTRUE
), thedisplay_cust
function is called to display the row in the form. - Line
6
If no rows were found and the direction is forward, indicated byp_fetch_flag
of1
, the cursor is past the end of the result set. - Line
8
If no rows were found and the direction is backward, indicated byp_fetch_flag
of-1
, the cursor is prior to the beginning of the result set.