Tutorial Chapter 11: Master/Detail / The Orders Program orders.4gl |
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.
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