SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-34
C Examples of DESCRIBE
GLOBAL | LOCAL
specifies the scope of the prepared statement. The default is LOCAL. A GLOBAL
prepared statement can be described and executed within the SQL session. A
LOCAL prepared statement can be described and executed only within the module
or compilation unit in which it was prepared.
A prepared SQL statement must be currently available whose name is the value of
ext-statement-name and whose scope is the same scope as specified in the
DESCRIBE INPUT statement.
USING SQL DESCRIPTOR descriptor-name
identifies the SQL descriptor area for the parameters of SQL-statement-name.
An SQL descriptor area must be currently allocated whose name is the value of
descriptor-name and whose scope is the same scope as specified in the
DESCRIBE statement.
When DESCRIBE INPUT executes, NonStop SQL/MX stores information for each
input parameter of the prepared statement. Each parameter has an item descriptor.
When DESCRIBE OUTPUT executes, NonStop SQL/MX stores information about
each column specified in the select list for the prepared statement. Each column
has an item descriptor.
descriptor-name
is a value-specification—a character literal or host variable with a
character data type. When DESCRIBE executes, the content of the host
variable (if used) gives the name of the descriptor area.
C Examples of DESCRIBE
Returns descriptions of input parameters for the prepared statement identified by
:stmt_name to an SQL descriptor area identified by the host variable
:input_sqlda:
EXEC SQL DESCRIBE INPUT :stmt_name
USING SQL DESCRIPTOR :input_sqlda;
Returns descriptions of output variables specified in the prepared statement
identified by S1 to the SQL descriptor area identified by the character literal
'output_sqlda':
EXEC SQL DESCRIBE OUTPUT S1
USING SQL DESCRIPTOR 'output_sqlda';
Prepare a statement, allocate input and output descriptor areas, and describe the
input and output descriptor areas:
...
strcpy(stmt_buffer,"SELECT * FROM EMPLOYEE"
" WHERE EMPNUM = CAST(? AS NUMERIC(4) UNSIGNED)");