Warnings in sqlca.sqlwarn

When the database server executes an SQL statement successfully, but encounters a warning condition, it updates the following two fields in the sqlca.sqlwarn structure:
  • It sets the sqlca.sqlwarn.sqlwarn0 field to the letter W.
  • It sets one other field within the sqlwarn structure (sqlwarn1 to sqlwarn7) to the letter W to indicate the specific warning condition.

These warnings are specific to HCL OneDB™. Fields of the sqlca structure contains two sets of warning conditions that can occur in the fields of the sqlca.sqlwarn structure. The first set of warnings, shown in Fields of the sqlca structure, occurs after the database server opens a database or establishes a connection. For more information about these conditions, see Determine features of the database server. The second set of warnings is for conditions that can occur as a result of other SQL statements.

To test for warnings, check whether the first warning field (sqlwarn0) is set to W. After you determine that the database server has generated a warning, you can check the values of the other fields in sqlca.sqlwarn to identify the specific condition. For example, if you want to find out what database a CONNECT statement has opened, you can use the code that the following figure shows.
Figure 1: Code fragment that checks for warnings after a CONNECT statement
int trans_db, ansi_db, us_db = 0;
⋮

msg = "CONNECT stmt";
EXEC SQL connect to 'stores7';
if(SQLCODE < 0)     /* < 0 is an error */
   err_chk(msg);
if (sqlca.sqlwarn.sqlwarn0 == 'W')
   {
   if (sqlca.sqlwarn.sqlwarn1 == 'W' )
      trans_db = 1;
   if (sqlca.sqlwarn.sqlwarn2 == 'W' ) 
      ansi_db = 1;
   if (sqlca.sqlwarn.sqlwarn3 == 'W' ) 
      us_db = 1;
   }