How to resolve the -305 error code in DB2?
And also please let me know, how to resolve the db2 error
codes.

Answer Posted / s

If a column contains nulls and you dont include a null
indicator variable in the program, the program receives a
-305 SQLCODE.
Even if no columns allow for nulls, it may be necessary to
use the null indicator to avoid a -305 SQLCODE. For eg, if
AVG(SAL) is computed and ther eare no employees in the
department, the result is null and a null indicator must be
ccoded on the SQL statement to avoid -305.
EXEC SQL SELECT SNAME
INTO :SNAME:SNAME-INDNULL
FROM S
WHERE SN = :SN-IN
END-EXEC
If SNAME has a value, SNAME-INDNULL contains 0.
If SNAME is NULL, SNAME-INDNULL contains -2.

Similarly, Inserting a NULL also required special handling.
If you are not providing a value for SNAME, a -1 can be
moved to the null indicator associated with the SNAME
column:

MOVE -1 to SNAME-INDNULL

EXEC SQL INSERT INTO S
(SN,SNAME,STATUS,CITY) VALUE
(:SN,:SNAME:SNAME-INDNULL,:STATUS,:CITY)
END-EXEC

Is This Answer Correct ?    23 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cobol db2?

743


What is package in db2 mainframe?

735


Mention the way of highlighting as well as putting a cursor to use in a cobol program.

848


What is blu acceleration in db2?

835


How do I optimize a query in db2?

834


What are concurrency issues?

815


Can one database have multiple instances?

803


Explain what are the various isolation levels possible?

813


Mention the length of physical storage of the given data types of db2 – date, timestamp, time

844


How can the duplicate values be eliminated from db2 select?

867


In an sql table that is embedded, what is the procedure to retrieve rows that are part of a db2 table?

857


Why do we bind in db2?

889


What is db2 bind?

817


Highlight all the advantages that are attached to a package.

886


What language is db2 written in?

792