SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Introduction
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
1-7
Using Dynamic SQL Cursors
•
Allocate the SQL descriptor area or areas for use by dynamic parameters.
•
Construct the SQL statement and store the statement in the declared host variable.
•
Prepare the SQL statement.
•
Describe the prepared statement using the SQL descriptor area or areas.
•
Set input parameter values in the input SQL descriptor area.
•
Execute the prepared statement.
•
Retrieve output parameter values (if any) from the output SQL descriptor area.
•
Deallocate resources held by the compiled statement and the SQL descriptor
areas.
See Section 9, Dynamic SQL.
Using Dynamic SQL Cursors
A dynamic SQL program that uses dynamic cursors typically includes declarations and
statements to:
•
Declare a host variable as a place to store the dynamic cursor specification.
•
Prepare the cursor specification.
•
Declare the cursor.
•
Open the cursor.
•
Retrieve the values at the cursor position.
•
Close the cursor.
You can also use SQL descriptor areas with dynamic SQL cursors. If you do, you must
describe the prepared cursor specification.
See Section 10, Dynamic SQL With Descriptor Areas.
Using DML Statements With Rowsets
Use rowsets to retrieve multiple rows from the database into the application for further
processing and to transfer multiple rows of values from the application to the database.
Rowset arrays can be used only from embedded SQL programs. NonStop SQL/MX
does not support rowsets from MXCI.
See Section 7, Static Rowsets and Section 12, Dynamic SQL Rowsets to learn how to
use rowsets in C/C++ or COBOL programs.
Improving Performance by Using Rowsets
Typically, you can use a cursor specified by the SELECT statement to return the
multiple rows that make up the result table of the SELECT to the application. Rows are
returned one at a time. However, the cursor mechanism can produce significant
overhead for an application retrieving many rows from the database.
Rowsets improve the performance of applications by manipulating multiple rows at
once, instead of one at time. Performance is improved because: