Accessing SQLCA variables

SQLCA variables are members of a C structure, sqlca, that is declared by the include sqlca statement. To access SQLCA variables, use the C structure member operator (.), as shown in the following example:

if (sqlca.sqlwarn[1] == ’W’)  
 { 
    printf("\nData truncated”); 
 return; 
 } 

You can also pass the address of the sqlca structure to a function, then access the SQLCA variables within that function with the -> operator. The following example shows a function that works this way:

warning(p)  
 struct sqlca *p;  
 { 
 if (p->sqlwarn[3] == ’W’) 
 {
    printf("\nIncorrect number of variables in
 fetch.\n"); 
 } 
 return;  
 
 }

SQLCA variables are useful for determining whether an Embedded SQL statement executed successfully. The other SQLCA variables listed in the previous section provide additional information about errors and return codes to help in debugging as well as the normal processing of your application.