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-32
Using SQL Descriptor Areas to Select SQL/MP
KANJI and KSC5601 Data
// assume the sql text is in :hv_sql_stmt
void execute_one_statement()
{
 EXEC SQL SET NAMETYPE 'NSK';
 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 statement
 EXEC SQL PREPARE sqlstmt FROM :hv_sql_stmt;
 // 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;
 if (j > 0)
 {
 // Get the type, character set name and length of the input 
 EXEC SQL GET DESCRIPTOR :in_sqlda VALUE :j
 :data_type = TYPE,
 :data_len = LENGTH,
 :charset_name = CHARACTER_SET_NAME;
 // Set up the input value based on character set name
 if ( strcmp(charset_name, SQLCHARSETSTRING_KANJI) == 0 ) {
 wchar_t temp[21];
 //0123456789012345678901234567890123456789
 strcpy((char*)temp, "Japan ");
 temp[20] = 0; // add the wide-char NULL for wcscpy
 wcscpy(hv_input_in_KANJI, (wchar_t*)temp);
 EXEC SQL SET DESCRIPTOR :in_sqlda VALUE :j 
 VARIABLE_DATA = :hv_input_in_KANJI;
 } else
Example A-10. Using SQL Descriptor Areas to Select SQL/MP KANJI and 
KSC5601 Data  (page3of5)










