Function order_fetch
This function retrieves the row from the orders
table, and is
designed to be reused each time a row is needed. If the retrieval of the row from the
orders
table is successful, the function items_fetch
is called to retrieve the corresponding rows from the items
table.
Function
order_fetch
(orders.4gl):01
FUNCTION
order_fetch(p_fetch_flag)
02
DEFINE
p_fetch_flag SMALLINT
03
04
IF
p_fetch_flag = 1 THEN
05
FETCH NEXT
order_curs INTO
order_rec.*
06
ELSE
07
FETCH PREVIOUS
order_curs INTO
order_rec.*
08
END IF
09
10
IF
(SQLCA.SQLCODE == NOTFOUND
) THEN
11
RETURN FALSE
12
END IF
13
14
DISPLAY BY NAME
order_rec.*
15
CALL
items_fetch()
16
RETURN TRUE
17
18
END FUNCTION
Note:
- Line
05
When the parameter passed to this function and stored in the variablep_fetch_flag
is 1, theFETCH
statement retrieves the next row from theorders
table. - Line
07
When the parameter passed to this function and stored inp_fetch_flag
is not 1, theFETCH
statement retrieves the previous row from theorders
table. - Lines
10
thru12
returnFALSE
if no row was found. - Line
14
usesDISPLAY BY NAME
to display the recordorder_rec
. - Line
15
calls the functionitems_fetch
, to fetch all order lines. - Line
16
returnsTRUE
indicating the fetch of the order was successful.