Contents of the SQLCA
One of the results of issuing the include sqlca statement is the declaration of the SQLCA (SQL Communications Area), which you can use for error handling in the context of database statements. As mentioned above, you should issue the statement in your main program and in each subprogram that contains Embedded SQL statements. The declaration for the SQLCA is:
common (sqlca) string sqlcaid = 8, &
long sqlcabc, &
long sqlcode, &
word sqlerrml, &
string sqlerrmc = 70, &
string sqlerrp = 8, &
long sqlerrd(5), &
string sqlwarn0 = 1, &
string sqlwarn1 = 1, &
string sqlwarn2 = 1, &
string sqlwarn3 = 1, &
string sqlwarn4 = 1, &
string sqlwarn5 = 1, &
string sqlwarn6 = 1, &
string sqlwarn7 = 1, &
string sqlext = 8
Note that the error diagnostic array, sqlerrd, is declared with 5 elements. This is because the BASIC compiler implicitly inserts element number zero before the declared array, so that there are really 6 array elements, as described in the SQL Reference Guide. A later section discusses the significance of sqlerrd for determining the number of rows affected by the last SQL statement.
The SQLCA is initialized at load-time. The fields sqlcaid and sqlabc are initialized to the string "SQLCA " and the constant 136, respectively.
Note that the preprocessor is not aware of the SQLCA declaration. Therefore, you cannot use SQLCA fields in an Embedded SQL statement. For example, the following statement, attempting to insert the error code sqlcode into a table, would generate an error:
! This statement is illegal
exec sql insert into employee (eno) &
values (:sqlcode)
All modules written in BASIC and other Embedded SQL languages share the same SQLCA.
Last modified date: 08/28/2024