DB2 Host Variables DB2 CURSOR


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.

	sqlcaid 	CHAR(8)
	sqlcabc 	INTEGE
	sqlcode 	INTEGER
	SQLCode means
		0 		- Successful execution(although one or more SQLWARN
		          	  indicators may be set).
		positive 	- Successful execution, but with a warning 
		negative 	- Error condition.
	sqlerrml 	SMALLINT
	sqlerrmc 	VARCHAR (70)
	sqlerrp 	CHAR(8)
	sqlerrd 	ARRAY
	sqlerrd(1) 	INTEGER
	sqlerrd(2) 	INTEGER 	
	sqlerrd(3) 	INTEGER
	sqlerrd(4) 	INTEGER 	
	sqlerrd(5) 	INTEGER 	
	sqlerrd(6) 	INTEGER
	sqlwarn 	Array
	sqlwarn0 	CHAR(1)
	sqlwarn1 	CHAR(1)
	sqlwarn2 	CHAR(1)
	sqlwarn3 	CHAR(1)
	sqlwarn4 	CHAR(1)
	sqlwarn5 	CHAR(1)
	sqlwarn6 	CHAR(1)
	sqlwarn7 	CHAR(1)
	sqlwarn8 	CHAR(1)
	sqlwarn9 	CHAR(1)
	sqlwarn10 	CHAR(1)
	sqlstate 	CHAR(5)

DB2 Host Variables DB2 CURSOR