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
Following a db2 update statement, what is the quickest way to compute the total number of updated rows?
How many databases can be created inside an instance in db2 ?
What is syscat in db2?
What is db2 command?
Which are the db2 tools to protect integrity of the database?
What is the difference between plan and package in db2?
What is a dbrm in db2?
Is ibm db2 free?
In case if at some point of time db2 is down, would that impact the pre-compilation process of a db2-cobol program?
How do you eliminate duplicate values in db2?
Explain dclgen.
What is cursor with hold option in db2?
How do you find the maximum value in a column in db2?
What is dbrm in db2 database?
What is the cobol picture clause of the db2 data types date, time, timestamp?