SQL/MX 3.2.1 Reference Manual (H06.26+, J06.15+)
Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Release 3.2.1 Reference Manual—691117-004
3-84
C Examples of SET DESCRIPTOR
•
Use arguments in an EXECUTE statement rather than descriptor areas. For more
information about dynamic SQL, see the SQL/MX Programming Manual for C and
COBOL.
•
If descriptor areas are used, use VARIABLE_DATA rather than
VARIABLE_POINTER.
Use VARIABLE_POINTER to efficiently retrieve individual values from a large buffer.
For more information on retrieving multiple values from a large buffer, see the SQL/MX
Programming Manual for C and COBOL.
VARIABLE_POINTER is not supported in COBOL. Embedded COBOL does not
support the pointer type.
Processing Items in a Descriptor Area
You can retrieve the number of filled-in descriptor items for input parameters and set
fields for a specific item. Use the number of filled-in descriptor items to construct a loop
to set values for individual parameters.
When a DESCRIBE statement executes, NonStop SQL/MX identifies parameters by
the context in which they appear in a prepared statement.
If you execute a DESCRIBE statement before a SET DESCRIPTOR statement, you
need not include TYPE in the SET DESCRIPTOR statement.
Version Differences for TYPE and TYPE_FS
In SQL/MX Release 1.0, the FS type (an SQL/MX extension) was equivalent to the
item TYPE, and the ANSI type was equivalent to the item TYPE_ANSI. In SQL/MX
Release 1.5 and later, to comply with ANSI standards, these equivalents have
changed. TYPE returns the ANSI type, and TYPE_FS returns the FS type (an SQL/MX
extension).
C Examples of SET DESCRIPTOR
•
Allocate a descriptor area, describe the input parameters of a dynamic SQL
statement, and use the descriptor area to set values for the parameters:
desc_max = 1;
EXEC SQL ALLOCATE DESCRIPTOR 'in_sqlda' WITH MAX :desc_max;
...
strcpy (hv_sql_statement, "UPDATE employee"
" SET salary = salary * 1.1"
" WHERE jobcode = CAST(? AS NUMERIC(4) unsigned)");
...
EXEC SQL PREPARE sqlstmt FROM :hv_sql_statement;
EXEC SQL DESCRIBE INPUT sqlstmt
USING SQL DESCRIPTOR 'in_sqlda';
...
scanf("%ld",&in_jobcode);
desc_value = 1;










