DB2 SQLCA

DB2 Host Variables DB2 CURSOR

Advertisements


SQLCA is called as a SQL communication Area.

SQLCA will have all the information like return code, error id, error details etc,. after the DB2 query execution.

SQLCA needs to be included in the COBOL + db2 program which will act as a communication area between COBOL and DB2 to validate the SQLs execution.

The major fields which are used in the program is SQLCODE, SQLERRD (3) among all.

SQLCODE is used to validate the return code of the particular execution once the SQL execution completed.

SQLCODE validation can be done like below.


If SQLCODE is ZERO, then the query executed successfully.

If SQLCODE is +ve, then the query executed successfully but there was a warning.

If SQLCODE is –ve, then the query executed with some errors.


SQLERRD (3) contains the number of rows executed by the particular operation.

The length of the SQLCA is 136.


SQLCA fields:


The below are the SQLCA fields with the data type and length.


NameData Type
SQLCAIDCHAR(8)
SQLCABCINTEGER
SQLCODEINTEGER
SQLERRMLSMALLINT
SQLERRMCVARCHAR (70)
SQLERRPCHAR(8)
SQLERRDARRAY
SQLERRD(1)INTEGER
SQLERRD(2)INTEGER
SQLERRD(3)INTEGER
SQLERRD(4)INTEGER
SQLERRD(5)INTEGER
SQLERRD(6)INTEGER
SQLWARNCHAR(1)
SQLWARN0CHAR(1)
SQLWARN1CHAR(1)
SQLWARN2CHAR(1)
SQLWARN3CHAR(1)
SQLWARN4CHAR(1)
SQLWARN5CHAR(1)
SQLWARN6CHAR(1)
SQLWARN7CHAR(1)
SQLWARN8CHAR(1)
SQLWARN9CHAR(1)
SQLWARN10CHAR(1)
SQLSTATECHAR(5)

DB2 Host Variables DB2 CURSOR

Advertisements