The SQLCA data structure contains status information about the Embedded SQL statement that was last executed. The structure definition for SQLCA (from SQLCA.H) looks like this:
// SQL Communication Area - SQLCA | |||
typedef struct sqlca | |||
{ | |||
unsigned char | |||
sqlcaid[EYECATCH_LEN]; | // Eyecatcher = 'SQLCA ' | ||
long sqlcabc; | // SQLCA size in bytes = 136 | ||
long sqlcode; | // SQL return code | ||
short sqlerrml; | // Length for SQLERRMC | ||
unsigned char | |||
sqlerrmc[SQLERRMC_SIZ]; | // Error message tokens | ||
unsigned char sqlerrp[8]; | // Diagnostic information | ||
long sqlerrd[6]; | // Diagnostic information | ||
unsigned char sqlwarn[8]; | // Warning flags | ||
unsigned char sqlext[3]; | // Reserved | ||
unsigned char sqlstate[5]; | // new member | ||
} SQLCA; |
Fields and datatypes for the SQLCA data structure are described in the following table.
Field and C datatype | Contains |
sqlcaid | |
unsigned char | The text string SQLCA. |
sqlabc | |
long | The length of the SQLCA data structure. |
sqlcode | |
long | The status code for the last-run SQL statement: |
0 The statement ran without error. | |
1 The statement ran, but an exception was generated. | |
100 A FETCH statement was issued, but no more rows satisfy the SELECT statement criteria that was used to define the cursor; no rows were processed. | |
< 0 (negative) The statement did not run due to an application, database, system, or network error. | |
sqlerrm | Error messages that consist of two parts. |
sqlerrml | The length of the error message in sqlerrmc (0 to 70). |
short | |
sqlerrmc | The text of the error message. Error messages that are longer than 70 bytes are truncated. |
unsigned char | |
sqlerrp | |
unsigned char | Reserved (diagnostic information). |
sqlerrd | |
long | An array of six integer status codes (the codes that are not listed in the fields below are reserved). |
sqlerrd[1] | SQL Server error number. |
sqlerrd[2] | SQL Server severity level. |
sqlerrd[3] | The number of rows affected. |
sqlwarn | Eight warning flags, each containing a blank or W (those not listed in the fields below are reserved): |
sqlwarn[0] | |
unsigned char | A summary of all warning fields. Blank indicates no warnings. |
sqlwarn[1] | |
unsigned char | W indicates that a character string was truncated during output binding. |
sqlwarn[2] | |
unsigned char | Not used. |
sqlwarn[3] | |
unsigned char | W indicates that the number of columns does not match the number of host variables. |
sqlext | |
unsigned char | Reserved. |
sqlstate | |
unsigned char | SQLSTATE runtime error codes. |
Warning
If the number of host variables and parameter markers does not match, SQLWARN3 is set to W. This condition is considered an exception (SQLCODE is set to +1). Exceeding the number of host variables or SQLDA data structure entries is fatal (SQLCODE = –19313). During a FETCH statement or a singleton select statement, SQLWARN3 is set if the number of columns is not equal to the number of host variables (or SQLDA data structure entries). The lower of the two is the number of items that are actually processed. For more information about SQLCA, see "Using the SQLCA Data Structure," in Chapter 2, "Embedded SQL Programming."