SQL/MP Programming Manual for C

SQL/MP System Procedures
HP NonStop SQL/MP Programming Manual for C429847-008
5-13
SQLCAGETINFOLIST
In Example 5-1, the SQLCAGETINFOLIST procedure returns the name of the function
containing the SQL statement that produced one or more errors or warnings, the name
length of the function, and the number of errors or warnings. To avoid coding the
maximum length for the function name (err_warn.name_len in the example), call
SQLCAGETINFOLIST with item code 7 (the actual length of the function name) and
then call SQLCAGETINFOLIST again with a buffer of that size.
Example 5-1. Example of the SQLCAGETINFOLIST Procedure
#include <cextdecs(SQLCAGETINFOLIST)>
...
#define MAX_NAME_LEN 30
#define ITEM_LIST_SIZE 3
struct /* structure to hold error information */
{
short name_len;
short num_errs;
char name[MAX_NAME_LEN];
} err_warn;
...
EXEC SQL INCLUDE SQLCA; /* include SQLCA structure */
short error_code; /* variable to hold return code */
/* Declare and initialize the item-list array */
short item_list[ITEM_LIST_SIZE]
= { 7, /* code for name length */
3, /* code for no of errors/warnings */
8 }; /* code for procedure ID */
...
error_code = SQLCAGETINFOLIST
( (short *) &sqlca, /* SQLCA structure */
item_list, /* list of item codes */
item_list_size, /* number of items */
(short*) &err_warn, /* result area */
sizeof err_warn, /* size of result area */
, /* no error index needed */
max_name_len ); /* Truncate names > 30 */
...