SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
11-1
11 Dynamic SQL Cursors
The dynamic SQL programs of NonStop SQL/MX use cursors to process multiple row 
SELECT statements in the same way that static SQL programs use cursors. The 
program reads rows from a result table, one by one, and sends the column values to 
output data buffers specified in the program. A static cursor is associated with an 
actual query expression (for example, a SELECT statement), and a dynamic cursor is 
associated with a statement prepared for the cursor specification.
This section describes:
•
Statements for Dynamic SQL Cursors on page 11-1
•
Steps for Using a Dynamic SQL Cursor on page 11-2
•
Dynamic SQL Cursors Using Descriptor Areas on page 11-10
Statements for Dynamic SQL Cursors
These statements are described on subsequent pages in this section. For the complete 
syntax of each statement, see the SQL/MX Reference Manual.
PREPARE Prepares (compiles) a dynamic SQL statement for 
subsequent execution.
DEALLOCATE PREPARE Deallocates a prepared statement, returns the system 
resources used by the statement, and allows reuse of 
the statement name.
DECLARE CURSOR  Defines a cursor and associates it with a statement 
already prepared for the cursor specification.
ALLOCATE CURSOR Allows you to dynamically declare an unlimited number 
of cursors.
OPEN Opens a cursor.
FETCH Positions a cursor on the next row of a table and 
retrieves values from the row. 
Positioned UPDATE  Updates a row from a table or view at the current 
cursor position.
Positioned DELETE  Deletes a row from a table or view at the current cursor 
position. 
CLOSE Closes a cursor. 










