Was this helpful?
Data Manipulation with Cursors
Cursors enable embedded OpenSQL programs to process the result rows returned by a SELECT statement, one at a time. After a cursor has been opened, it can be advanced through the result rows. When the cursor is positioned to a row, the data in the row can be transferred to host language variables and processed according to the requirements of the application. The row to which the cursor is positioned is referred to as the current row.
A typical cursor application uses OpenSQL statements to perform the following steps:
1. Declare a cursor that will select a set of rows for processing.
2. Open the cursor, thereby selecting the data.
3. Fetch each row from the result table and move the data from the row into host language variables.
4. Optionally update or delete the current row.
5. Close the cursor and terminate processing.
Last modified date: 12/14/2023