SQL Programming Manual for Pascal

NonStop SQL System Procedures
HP NonStop SQL Programming Manual for Pascal528614-001
4-18
SQLCATOBUFFER
SQLCATOBUFFER works by starting with the first-record-number indicated
to move output lines to the record area until all error messages are moved or until
the text fills the record area. SQLCATOBUFFER returns to output-records a
count of the lines moved to the buffer. If an overflow occurs, the procedure sets the
more flag to Y.
On an overflow condition, your program can retrieve the rest of the error message
text by calling SQLCATOBUFFER again, setting first-output-record to
output-records + 1.
Examples
Suppose that you use a 75-character output record and declare a buffer as 375
characters. The following example declares an SQLMSG file number and initializes the
file number to -1. The call returns the file number so that subsequent calls retain the
number.
?SOURCE $ volume. subvolume.PEXTDECS
...
SQLMSG_BUFFER := ' ';
FIRST_RECORD_NUMBER := 1;
OUT_RECORD_LENGTH := 75;
SQLCATOBUFFER (XADDR(SQLCA),
SQLMSG_BUFFER,
,
,
OUT_RECORD_LENGTH,
SQLMSG_FILENUM);
This example uses the value in MORE to control a loop that fetches errors into the
output buffer. Note that you must increment FIRST_RECORD_NUMBER to get each
subsequent message.
?SOURCE $ volume. subvolume.PEXTDECS
...
SQLMSG_BUFFER := ' ';
FIRST_RECORD_NUMBER := 1;
OUT_RECORD_LENGTH := 75;
REPEAT
SQLCATOBUFFER ( XADDR (SQLCA) ),
SQLMSG_BUFFER,
FIRST_RECORD_NUMBER,
,
MORE,
75 )
FIRST_RECORD_NUMBER := FIRST_RECORD_NUMBER + 1;
UNTIL ( MORE = ORD('N') );