Progress
Embedded SQL-92
Guide and Reference


Using an SQLCA to Check for Warnings

You can use an SQLCA to check for warnings that occur during the execution of an SQL statement. The component SQLWARN of SQLCA is an array of eight characters. Each element of the array can be either a blank or a `W'.

Currently Progress uses the elements 0, 1, 2, 3, 4, and 6 of the SQLWARN array. These are the conditions under which warning flags are set:

EXAMPLE

The following example computes the average commission for employees in the sales department, and shows how to evaluate the SQLWARN array to check for null values in the data:

EXEC SQL BEGIN DECLARE SECTION ; 
     FLOAT  comm_v ; 
EXEC SQL END DECLARE SECTION ; 
   . 
   . 
    . 
EXEC SQL CONNECT TO DEFAULT ; 
EXEC SQL 
     SELECT AVG (commission) 
     INTO :comm_v 
     FROM employee 
     WHERE deptno = 20 ; 
  
if (sqlca.sqlcode == 0) 
{ 
     printf ("commission : %d", comm_v) ; 
     /* 
     ** Select statement completed; also check SQLCA for warnings 
     */ 
     if (sqlca.sqlwarn[2] == 'W') 
     { 
          printf ("One or more NULL values were ignored\n") ; 
          printf ("in the computation of average commission.\n") ; 
     } 
} 

This example evaluates the SQLWARN[2] component of the SQLCA to determine if any NULL values were ignored in the computation of the average commission.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095