When an SQL SELECT statement in your application will retrieve more
than one row, a cursor must be used to pass the selected data to the program one row at a
time.
Using Cursors
The cursor is a data structure that represents a specific location within the active set of rows that the SELECT statement retrieved.
The SQLCA.SQLCODE
The SQLCA name stands for "SQL Communication Area". The SQLCA variable is a predefined record containing information on the execution of an SQL statement.
Example custquery.4gl (function cust_select)
This function is called by the function query_cust, if the row count returned by the function get_cust_cnt indicates that the criteria previously entered by the user and stored in the variable where_clause would produce an SQL SELECT result set.
Example: custquery.4gl (function fetch_cust)
This function is designed so that it can be reused each time a row is to be fetched from the customer database table; a variable is passed to indicate whether the cursor should move forward one row or backward one row.