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 dpf in db2?

666


What is the syntax for seeing the columns and data types of a table in the db2 database?

578


How do I delete a table in database?

599


Why do we need reorg in db2?

566


What is multi row fetch in db2?

610






Is db2 a mainframe?

591


What is copy pending status in db2?

638


SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD CHAR, TOKEN KEY was expected

10777


Define data page.

634


What is blu acceleration in db2?

608


Which isolation level provides highest data integrity?

599


If anyone has IBM Certification Dumps pls forward to me & also let me know what are the Certification Codes that are available in DB2

1580


What is dclgen (declaration generator)?

603


How to retrieve rows from a db2 table in embedded sql?

730


What does reorg do in db2?

578