Retrieve data: the SQLCursor class
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Methods of the SQLCursor class
let stored procedures retrieve rows of data. When stored procedures
create an object from the SQLCursor class, they
pass as an argument an SQL statement that generates a result set.
The SQL statement is either a SELECT or a CALL statement:
- A
SELECTstatement queries the database and returns data that meets the criteria specified by the query expression in theSELECTstatement. - A
CALLstatement invokes another stored procedure that returns a result set specified by theRESULTclause of theCREATE PROCEDUREstatement.
Either
way, once the procedure creates an object from the SQLCursor class,
the processing of result sets follows the same steps.
To process result sets:
-
Open the cursor by using the
SQLCursor.openmethod. -
Check whether there are any records in the result set
by using the
SQLCursor.foundmethod. -
If there are records in the result set, loop through
the result set to:
- Fetch a record by using the
SQLCursor.fetchmethod. - Check whether the fetch returned a record with the
SQLCursor.foundmethod. - Assign values from the result‑set record's fields to procedure variables
or procedure output parameters by using the
SQLCursor.getValuemethod. - Process the data, or
- Exit the loop if the fetch operation did not return a record.
- Fetch a record by using the
-
Close the cursor by using the
SQLCursor.closemethod.
The following example uses SQLCursor to
process the result set returned by an SQL SELECT statement.
|
Stored procedures also use SQLCursor objects
to process a result set returned by another stored procedure. Instead
of a SELECT statement, the SQLCursor constructor
includes a CALL statement that invokes the desired
procedure.
The following example shows an excerpt from a stored
procedure that processes the result set returned by another procedure, get_customers.
|