EasyManua.ls Logo

HP NonStop SQL/MP

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C429847-008
10-27
Perform the Database Request and Display the
Values
Perform the Database Request and Display the Values
Assign a name to the cursor host variable:
char cursor_name[11];
strncpy (cursor_name, "c1", 2);
If the statement is a SELECT statement, follow these steps:
1. Declare a cursor for the statement:
EXEC SQL DECLARE :cursor_name CURSOR FOR :statement_name;
2. Begin a TMF transaction:
EXEC SQL BEGIN WORK;
3. Open the cursor:
EXEC SQL OPEN :cursor_name
USING DESCRIPTOR :*input_sqlda_ptr;
4. Execute a loop to fetch the values and display them:
EXEC SQL FETCH :cursor_name
USING DESCRIPTOR :*output_sqlda_ptr;
Display the values in a format according to data type. (For a repetitive display of
column names, use the output names buffer at this point and omit Step 6 of
Process the Output Variables on page 10-25.)
Handle null values as follows:
If null_info is -1, check the value indicated by ind_ptr.
If ind_ptr is also -1, display a character representing a null value (for
example, a blank or zero). Otherwise, display the value indicated by ind_ptr.
If you are ignoring null values, display the value indicated by var_ptr.
5. Close the cursor:
EXEC SQL CLOSE :cursor_name;
If the statement is not a SELECT statement, follow these steps:
1. Begin a TMF transaction:
EXEC SQL BEGIN WORK;
2. Run the statement:
/* If there were input parameters: */
EXEC SQL EXECUTE :statement_name
USING DESCRIPTOR :*input_sqlda_ptr;
/* If there were no input parameters: */
EXEC SQL EXECUTE :statement_name;

Table of Contents

Related product manuals