get diagnostics

Description

Retrieves error, warning, and informational messages from Client-Library.

Syntax

get diagnostics 
 {:hv = statement_info [, :hv = statement_info]…| 
 exception :condition_number 
 :hv = condition_info [, :hv = condition_info]…}

Parameters

statement_info

The keyword number is currently the only supported statement_info type. It returns the total number of exceptions in the diagnostics queue.

condition_info

Any one of the keywords sqlca_info, sqlcode_number, and returned_sqlstate.

Examples

Example 1

exec sql begin declare section;
     CS_INT   num_msgs;
     CS_INT   condcnt=1;
     exec sql include sqlca;
 exec sql end declare section;
 exec sql exec sp_password "bass", "foo";
 exec sql get diagnostics :num_msgs = number;
printf("Number of messages is %d.\n", num_msgs);
 
 /* Loop through and print the messages. */
 
 while (condcnt <= num_msgs)
 {
     exec sql get diagnostics exception :condcnt
          :sqlca = sqlca_info;
    printf("SQLCODE = %d  \n", sqlca.sqlcode);
     printf("%s \n", sqlca.sqlerrm.sqlerrmc);
     condcnt = condcnt + 1;
 }

Usage

See also

whenever