SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
C Sample Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
A-37
Using SQL Descriptors to Select UCS2 Data
// assume the sql text is in :hv_sql_stmt
void execute_one_statement()
{
strcpy (in_sqlda," ");
strcpy (out_sqlda," ");
strcpy(in_sqlda,"selargs");
in_sqlda[13] = '\0';
strcpy(out_sqlda,"selcols");
out_sqlda[13] = '\0';
// Allocate the descriptor for input parameters
hv_desc_max = 1;
EXEC SQL ALLOCATE DESCRIPTOR :in_sqlda WITH MAX :hv_desc_max;
// Allocate the descriptor for output values
hv_desc_max = 6;
EXEC SQL ALLOCATE DESCRIPTOR :out_sqlda WITH MAX \
:hv_desc_max;
// Prepare the cursor statement
EXEC SQL PREPARE sqlstmt FROM :hv_sql_stmt;
// Declare the dynamic cursor from the prepared statement
EXEC SQL DECLARE cur_name CURSOR FOR sqlstmt;
// Describe the SQL descriptor area for input parameter
EXEC SQL DESCRIBE INPUT sqlstmt USING SQL DESCRIPTOR
:in_sqlda;
// Describe the SQL descriptor area for SELECT values
EXEC SQL DESCRIBE OUTPUT sqlstmt USING SQL DESCRIPTOR
:out_sqlda;
// Get the input count
j = 0;
EXEC SQL GET DESCRIPTOR :in_sqlda :j = COUNT;
Example A-11. Using SQL Descriptors to Select UCS2 Data (page 3 of 5)