Reading and scrolling through result sets in embedded SQL applications
One of the most common tasks of an
embedded SQL application program is to retrieve data. You can retrieve
data by using the select-statement, which is a form of query
that searches for rows of tables in the database that meet specified
search conditions.
If such rows exist,
the data is retrieved and put into specified variables in the host
program, where it can be used for whatever it was designed to do.
Note: Embedded SQL applications can call stored procedures with any
of the supported stored procedure implementations and can retrieve
output and input-output parameter values, however embedded SQL applications
cannot read and scroll through result sets returned by stored procedures.
After you have written a select-statement, you code the SQL statements that define how information will be passed to your application.
You can think of the result of a select-statement as being a table having rows and columns, much like a table in the database. If only one row is returned, you can deliver the results directly into host variables specified by the SELECT INTO statement.
If more than one row is returned, you must use a cursor to fetch them one at a time. A cursor is a named control structure used by an application program to point to a specific row within an ordered set of rows.