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

by using cursors , we can access particular records from the table based on some condition, i want to delete those selected records, how can we write a query for this in the program?

7476


How can you count the number of rows from a table tab?

627


How do I delete a column in db2?

669


Explain in detail about buffer manager and its functionalities?

553


How and when does the db2 enforces the unique key?

609






How do I start db2 in windows?

554


Define data page.

624


What is bind and rebind in db2?

640


What is the physical storage length of the data types date, time, and timestamp?

593


How to get the ddl of a table in db2?

670


Which component is responsible for db2 startup and shutdown?

618


What is release/acquire in bind?

641


How can the duplicate values be eliminated from db2 select?

617


can we view the access paths created by dbrm ? how ? thx

6230


What is an instance database?

589