What will happen if a NULL value is detected for a SQL statement in COBOL-DB2 program and the NULL indicator is not used?


There is no concept of NULL in COBOL language. Therefore, if any of the columns in DB2 table can hold NULL value then we need to give the NULL indicator in SELECT query in order to detect the NULL value.

However, if we miss to give the null indicator in the SELECT query and any of the columns contains the NULL value then the query will fail and we will get a value of -305 in SQLCODE field of SQLCA. As per the IBM documentation -305 value states that.

“THE NULL VALUE CANNOT BE ASSIGNED TO OUTPUT HOST VARIABLE NUMBER position-number BECAUSE NO INDICATOR VARIABLE IS SPECIFIED”

Updated on: 14-Sep-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements