Close and Free the Cursor
Closing and freeing the cursor when you no longer need it is good practice, especially if the modules are part of a larger program.
This function must be placed in the same module as the
DECLARE/OPEN/FETCH statements and
in sequence, so this is the last function in the query_cust module.
However, the function can be called from cust_main, as a final
"cleanup" routine.
Function cleanup
(custquery.4gl)
01 FUNCTION cleanup()
02 WHENEVER ERROR CONTINUE
03 CLOSE cust_curs
04 FREE cust_curs
05 WHENEVER ERROR STOP
06 END FUNCTIONNote:
-
Line
03Closes the cursor used to retrieve the database rows. -
Line
04Frees the memory associated with the cursor. -
Lines
02and05TheWHENEVER ERRORstatements prevent a program error if the user exited the program without querying, and the cursor was never created.