SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Dynamic SQL With Descriptor Areas
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
10-6
Setting Input Parameter Information Without
DESCRIBE INPUT
Setting Input Parameter Information Without DESCRIBE INPUT
Use the SET DESCRIPTOR statement to describe the input parameters explicitly,
without using DESCRIBE INPUT. To use this method, set the values for these fields (if
needed for the particular data type):
TYPE_FS (or TYPE)
DATETIME_CODE
LEADING_PRECISION
PRECISION
SCALE
CHARACTER_SET_NAME
LENGTH
INDICATOR_TYPE
INDICATOR_DATA (or INDICATOR_POINTER)
VARIABLE_DATA (or VARIABLE_POINTER)
ROWSET_VAR_LAYOUT_SIZE
ROWSET_IND_LAYOUT_SIZE
The data type of the input parameter determines the fields that need to be set.
Example
This example uses a typical context for input parameters in dynamic SQL. This
example does not use the DESCRIBE INPUT statement.
strcpy(hv_sql_stmt, "UPDATE samdbcat.persnl.employee"
" SET salary = salary * 1.1"
" WHERE jobcode = CAST(? AS NUMERIC(4) UNSIGNED)");
/* Allocate the descriptor area for input parameters. */
desc_max=1;
EXEC SQL ALLOCATE DESCRIPTOR 'in_sqlda' WITH MAX :desc_max;
...
/* Prepare the statement. */
EXEC SQL PREPARE sqlstmt FROM :hv_sql_stmt;
...
scanf("%hu", &in_jobcode);
...
/* Set the value of the input parameters in */
/* the input SQL descriptor area. */
desc_value = 1;
desc_type = -502; /* Smallint unsigned. */
desc_precision = 4;
desc_scale = 0;
EXEC SQL SET DESCRIPTOR 'in_sqlda' VALUE :desc_value
TYPE = :desc_type,
PRECISION = :desc_precision,
SCALE = :desc_scale,
VARIABLE_DATA = :in_jobcode;
...
EXEC SQL EXECUTE sqlstmt
USING SQL DESCRIPTOR 'in_sqlda';
C