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

Highlight all the advantages that are attached to a package.

639


What is difference between alias and synonym in db2?

656


can all users have the privilage to use the sql statement select * (dml)?

652


For a db2 column that is being defined as decimal (11, 2), discuss the cobol picture clause.

672


what is a corelated subquerry?

672






What is a trigger in the db2 database?

606


How to resolve deadlock issue

18077


define clustering index.

629


What is the difference between "db2ilist" and "db2 get instance" commands in DB2 Database Server?

726


What is the use of dclgen in db2?

604


How to take backup of table in db2?

609


Can there be more than one cursor open for any program?

672


What is reorg?

628


My sql statement select avg(salary) from emp yields inaccurate results. Why?

653


What is the maximum size of a char data type in db2?

594