SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)
Static Rowsets
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL—663854-002
7-11
Selecting Rows Into Rowset Arrays
void display_diagnosis()
{
exec sql get diagnostics :hv_num = NUMBER;
memset(hv_msgtxt,' ',sizeof(hv_msgtxt));
hv_msgtxt[512]='\0';
printf("Number : %d\n", hv_num);
for (i = 1; i <= hv_num; i++) {
exec sql get diagnostics exception :i
:hv_sqlcode = SQLCODE,
/* this gets the row number which is causing the unique
constraint error */
:hv_rownum = ROW_NUMBER,
:hv_msgtxt = MESSAGE_TEXT;
printf("Sqlcode : %d\n", hv_sqlcode);
printf("Message : %s\n", hv_msgtxt);
printf("RowNum : %d\n", hv_rownum);
}
}
The output for the example is as follows:
test1: Expecting rownumber = 9
Number : 1
Sqlcode : -8102
Message : *** ERROR[8102] The operation is prevented by a unique
constraint.
RowNum : 9
Failed to insert. SQLCODE = -8102
Selecting a Column With Date-Time or INTERVAL Data Type
If a column in the select list has an INTERVAL or standard date-time (DATE, TIME, or
TIMESTAMP, or the SQL/MP DATETIME equivalents) data type, use the INTERVAL or
date-time data types.










