SQL Server uses the SQL communications area (SQLCA) data structure to trap and report run-time errors to your Embedded SQL applications. Your application can check the error fields and status indicators of the SQLCA data structure to determine the success or failure of an Embedded SQL statement. The precompiler automatically includes the SQLCA data structure in Embedded SQL applications.
You can include routines in your application to test the SQLCODE, SQLWARN, SQLERRM, SQLERRD, and SQLSTATE fields of the SQLCA data structure and to provide followup procedures according to the status that is returned. The SQLCODE field contains the negative SQL Server error code (the Embedded SQL standard requires that error codes be negative). The SQLWARN flags are set if certain exceptions, such as data truncation, occur. The SQLERRD1 field contains the error number; the SQLERRMC field contains the text of the error message. The SQLERRD3 array indicates the number of rows that are affected. The SQLSTATE field contains run-time errors that generate ANSI-standard SQLSTATE codes.
Because the character fields of SQLCA (like SQLWARN and SQLERRMC) are FAR pointers in Windows, you must use the %Fs format specifier for them when using printf and similar functions.
For more information about the SQLCA data structure, see Appendix A, "Advanced Programming."