Database Reference
In-Depth Information
WARNING_LABEL:
fprintf(stderr, "\nSQL WARNING occur and captured using
SQLWARNING condition\n");
EXEC SQL DISCONNECT ALL;
return 1;
}
Using sqlca for error handling
SQL Communication Area ( sqlca ) is a C structure and can be used to get the
detailed information about the error.
The structure is as follows:
struct
{
charsqlcaid[8];
longsqlabc;
longsqlcode;
struct
{
intsqlerrml;
charsqlerrmc[SQLERRMC_LEN];
} sqlerrm;
charsqlerrp[8];
longsqlerrd[6];
charsqlwarn[8];
charsqlstate[5];
} sqlca;
Here is the complete example of ECPG program to print the detailed information
about the error-like code and error message. The print_sqlca() function prints
every ield of the sqlca structure. In case of SQLERROR and print_sqlca() function
will be called and will print the details of error as follows:
EXEC SQL WHENEVER SQLERROR CALL print_sqlca();
The following example shows detailed information about the error-like code and
error messages:
/*----------------------------------------------------------------
*
*ecpg_sqlca.pgc
*Communicating PostgreSQL Server using ECPG
*
 
Search WWH ::




Custom Search