SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

C Sample Programs
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
A-24
Using a Dynamic SQL Cursor With Descriptor Area
case -301:
printf ("Decimal unsigned: %s, Type: %d, Precision: %d,"
" Scale: %d,\n Length: %d, Null: %d",
hv_name, hv_type, hv_precision,
hv_scale, hv_length, hv_indicator);
EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i
:hv_double = VARIABLE_DATA;
if (hv_scale > 0) {
hv_double = hv_double/pow(10,hv_scale);
printf (" Value: %f\n", hv_double);
} else printf (" Value: %.f\n", hv_double);
break;
case -201:
case -401:
printf ("Integer unsigned: %s, Type: %d, Precision: %d,"
" Scale: %d,\n Length: %d, Null: %d",
hv_name, hv_type, hv_precision,
hv_scale, hv_length, hv_indicator);
EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i
:hv_double = VARIABLE_DATA;
if (hv_scale > 0) {
hv_double = hv_double/pow(10,hv_scale);
printf (" Value: %f\n", hv_double);
} else printf (" Value: %.f\n", hv_double);
break;
case -402:
printf ("Largeint: %s, Type: %d, Precision: %d,"
" Scale: %d,\n Length: %d, Null: %d",
hv_name, hv_type, hv_precision,
hv_scale, hv_length, hv_indicator);
EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i
:hv_longval = VARIABLE_DATA;
printf (" Value: %Ld\n", hv_longval);
break;
case -502:
printf ("Smallint unsigned: %s, Type: %d, Precision: %d,"
" Scale: %d,\n Length: %d, Null: %d",
hv_name, hv_type, hv_precision,
hv_scale, hv_length, hv_indicator);
EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i
:hv_short = VARIABLE_DATA;
printf (" Value: %hu\n", hv_short);
break;
default:
printf ("Invalid or unspecified type: %s,"
"Type: %d, Length: %d, Null: %d",
hv_name, hv_type, hv_length, hv_indicator);
break;
} /* end switch hv_type*/
} /* end for */
} /* end assign_to_hv */
Example A-7. Using a Dynamic SQL Cursor With Descriptor Areas (page 7 of 8)