SQL Programming Manual for Pascal

NonStop SQL System Procedures
HP NonStop SQL Programming Manual for Pascal528614-001
4-13
SQLCAGETINFOLIST
TYPE ERR_WARN_TYPE = RECORD
NAME_LEN : INT16; { 2 bytes }
NUM_ERRS : INT16; { 2 bytes }
NAME : FSTRING(MAX_NAME_LEN); { 30 bytes }
ERR_CODE : INT16; { 2 bytes }
END;
VAR ERR_WARN_RESULT : ERR_WARN_TYPE;
{ Include the SQLCA declaration: }
EXEC SQL INCLUDE SQLCA;
{ Declare a variable to hold the return code for the call: }
VAR CALL_ERROR : INT16;
{ Declare a variable to hold the index of the entry for }
{ which you want information: }
VAR ERROR_ITEM: INT16;
{ Declare the itemlist array: }
VAR ITEMLIST : ARRAY [1..4] OF INTEGER;
{ Initialize the itemlist array: }
ITEMLIST[1] := 7; { code for actual name length }
ITEMLIST[2] := 3; { code for actual number of }
{ errors/warnings }
ITEMLIST[3] := 8; { code for procedure name }
ITEMLIST[4] := 22; { code for error number }
...
{ Assign a value to ERROR_ITEM to tell SQL to provide }
{ information about this entry in the errors array: }
ERROR_ITEM := 5;
{ Call SQLCAGETINFOLIST. The third parameter is the number }
{ of codes you are supplying in itemlist. MAX_NAME_LEN will}
{ cause the program to truncate all names to 30 characters. }
CALL_ERROR := SQLCAGETINFOLIST
( XADDR(SQLCA),
XADDR(ITEMLIST),
4,
XADDR(ERR_WARN_RESULT),
UNFILLED SIZEOF(ERR_WARN_RESULT),
,
MAX_NAME_LEN,
,
,
XADDR(ERROR_ITEM)
);
To avoid hard coding the maximum length for the procedure name
(ERR_WARN_RESULT.NAME_LEN in this example), follow these steps: