SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-29
Performing the Database Request
After DESCRIBE INPUT executes and for each input parameter described in an
SQLVAR array in the input SQLDA, SQL/MP sets NULL-INFO to -1 if the input
parameter in the prepared statement could have a null value (that is, if the prepared
statement included a null indicator parameter).
If the user specifies a null value for the parameter, set the Working-Storage location
referenced by IND-PTR to -1. SQL/MP checks this value and assumes a null value for
the parameter.
If instead the user does not enter a null value for the input parameter, you can assign a
0 to the location pointed to by IND-PTR. SQL/MP checks IND-PTR, sees that IND-PTR
indicates a nonnull value, and gets the parameter value from the Working-Storage
location pointed to by VAR-PTR for the parameter value.
Performing the Database Request
An application must process statements that are not SELECT statements differently
than SELECT statements.
Processing NonSELECT Statements
To determine if a statement is not a SELECT statement, check SQL-STATEMENT-
TYPE OF SQLSA to see if it equals 0. If so, perform these steps:
1. Begin a TMF transaction:
EXEC SQL BEGIN WORK END-EXEC.
(Depending on your transaction definition you might not want to do this for every
statement.)
2. Execute a statement other than a SELECT statement.
If there were input parameters:
EXEC SQL EXECUTE S1
USING DESCRIPTOR :IN-SQLDA END-EXEC.
If there were no input parameters:
EXEC SQL EXECUTE S1 END-EXEC.
3. End the TMF transaction (for both SELECT and other statements):
EXEC SQL COMMIT WORK END-EXEC.
(Depending on your transaction definition you might not want to do this for every
statement.)
Note. The DESCRIBE INPUT statement sets the NULL-INFO field, depending on whether the
prepared SQL statement includes a null indicator and not on whether the column in the table
supports a null value. To determine if a column allows a null value, check the NULLALLOWED
column in the COLUMN catalog table for the catalog where the table is registered.