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-38
Using SQL Descriptors to Select UCS2 Data
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. Use
// the relaxation feature to compare an UCS2 string with
// an ISO88591 or UCS2 column.
if ( strcmp(charset_name, SQLCHARSETSTRING_UNICODE) == 0 ||
strcmp(charset_name, SQLCHARSETSTRING_ISO88591) == 0 )
{
//01234567890123
wcscpy(hv_input_in_UCS2, L"Houston ");
data_len = wcslen(hv_input_in_UCS2)+1;
EXEC SQL SET DESCRIPTOR :in_sqlda VALUE :j
VARIABLE_DATA = :hv_input_in_UCS2;
} else
return;
}
// Open the cursor using the input SQLDA
EXEC SQL OPEN cur_name USING SQL DESCRIPTOR :in_sqlda;
// Fetch the first row into output SQLDA
EXEC SQL FETCH cur_name INTO SQL DESCRIPTOR :out_sqlda;
// Get the count of the number of output values
EXEC SQL GET DESCRIPTOR :out_sqlda :degree = COUNT;
while ( strcmp(SQLSTATE, SQLSTATE_NODATA) != 0 ) {
Example A-11. Using SQL Descriptors to Select UCS2 Data (page 4 of 5)