Contents of the SQLCA
One of the results of issuing the include sqlca statement is the declaration of the SQLCA record, which can be used for error handling in the context of database statements. You should only issue the statement once in a particular Pascal scope, because it generates an external record variable definition. The nested record declaration for the SQLCA is:
type
IISQLCA = record
sqlcaid: packed array[1..8] of Char;
sqlcabc: Integer;
sqlcode: Integer;
sqlerrm: varying[70] of Char;
sqlerrp: packed array[1..8] of Char;
sqlerrd: array[1..6] of Integer;
sqlwarn: record
sqlwarn0: Char;
sqlwarn1: Char;
sqlwarn2: Char;
sqlwarn3: Char;
sqlwarn4: Char;
sqlwarn5: Char;
sqlwarn6: Char;
sqlwarn7: Char;
end;
sqlext: packed array[1..8] of Char;
end;
var
sqlca: [common] IISQLCA;
The record member sqlerrm is a varying length character string which Pascal stores as if it were declared as:
sqlerrm: record
length : [word] 0..70;
body : packed array[1..70] of Char;
end;
Here "length" corresponds to the standard SQLCA variable sqlerrml and "body" corresponds to the standard SQLCA variable sqlerrmc. For a full description of all the SQLCA record members, see the SQL Reference Guide.
The SQLCA is initialized at load-time. The fields sqlcaid and sqlcabc are initialized to the string "SQLCA " and the constant 136, respectively.
Note that the preprocessor is not aware of the record declaration. Therefore, you cannot use members of the record in an Embedded SQL statement. For example, the following statement, attempting to insert the string "SQLCA" into a table, would generate an error:
exec sql insert into employee (ename) {This statement is illegal}
values (:sqlca.sqlcaid);
All modules written in Pascal and other embedded languages share the same SQLCA.