Was this helpful?
The Include SQLCA Statement
In order to handle SQL database errors, you can issue the include sqlca statement at the outermost scope of your C file. If the file is made up of one main procedure that issues embedded SQL statements, it must be the first embedded SQL statement in the procedure:
Emp_Update()
{
    exec sql include sqlca;
    /* Declarations and embedded statements */
}
If the file is made up of a few procedures that issue embedded SQL statements, the include sqlca must be issued outside any of the procedures:
exec sql include sqlca;
 Emp_Util_1()
{
    /*
    ** Declarations & embedded statements for Emp_Util_1
    */
}
Emp_Util_2()
{
    /*
    ** Declarations & embedded statements for Emp_Util_2
    */
}
The include sqlca statement instructs the preprocessor to generate code that includes references to the SQLCA structure for error handling on database statements. It generates a C include directive to a file that defines the SQLCA structure.
You only need to issue the include sqlca statement if you intend to use the SQLCA for error handling. Some error handling mechanism should be included before all executable embedded SQL database statements because the default action is to ignore errors, which is rarely desirable.
Last modified date: 01/30/2023