Defining the SQL communications area, SQLSTATE, and SQLCODE in assembler
Assembler programs that contain SQL statements can include an SQL communications area (SQLCA) to check whether an SQL statement executed successfully. Alternatively, these programs can declare individual SQLCODE and SQLSTATE host variables.
About this task
If you specify the SQL processing option STDSQL(YES), do not define an SQLCA. If you do, Db2 ignores your SQLCA, and your SQLCA definition causes compile-time errors. If you specify the SQL processing option STDSQL(NO), include an SQLCA explicitly.
If your application contains SQL statements and does not include an SQL communications area (SQLCA), you must declare individual SQLCODE and SQLSTATE host variables. Your program can use these variables to check whether an SQL statement executed successfully.
Procedure
To define the SQL communications area, SQLSTATE, and SQLCODE:
Option | Description |
---|---|
To define the SQL communications area: |
|
To declare SQLCODE and SQLSTATE host variables: |
Restriction: Do not declare an SQLSTATE variable
as an element of a structure.
Requirement: After you declare the SQLCODE and SQLSTATE variables,
ensure that all SQL statements in the program are within the scope
of the declaration of these variables.
|