Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nulls not Null 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a problem I am wondering if anyone has a solution to.

I am doing a SELECT(MAX) in a COBOL program and getting a -305 SQLCODE returned. I have looked this up and it seems to be indicating I need a NULL indicator defining on my SQL. However on closed examination I have found there to be no columns in the table which allows NULLS? How can this be?

Anyone any ideas out there?
 
If you select a MAX, MIN, SUM, etc of a column and the WHERE clause does not qualify any rows on the table, DB2 returns a -305 to your programs.

Taking the code

select max (salary) into :hvsalary from employees where office = '12'

If no employees are in office 12 then DB2 tries to return a NULL to a host variable. It does not as most people expect it to do return a +100. In this instance it will return a -305 as no host variable exists for the Null Indicator.

Remedy is to either code a Null Indicator on your SQL or test for -305.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top