niharika1234 New User Joined: 01 May 2006 Posts: 9
My table one date field is declared to be as null..... when writing the code , during fetch the date i am getting SQLCODE -305I.E. null values cannot be assined to the field..... how to handle in the code?
thanks in advance
vicky10001 Warnings : 1 Active User Joined: 13 Jul 2005 Posts: 136
Please Use below code like this
shreevamsi Active User Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
What is the scenario that made you retrieve the NULL INDICATOR of a Variable in the CObol program.
NULL -Indicators are for tables to handle the NULL - condition.
I think u don't need to explicitly move the Indicator to the Field in cobol.
When you fetch a field to a variable......
DATABASE-VARIABLE :DATABASEVARIABLE-ID(null indicator)
DavidatK Active Member Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
There are a couple of things you can do to handle null values coming into your COBOL program.
As stated above, there is a ?null indicator? you can place on the host variable that will tell you if the column value is null or not.
It in the form of:
The HOST-NULL-IND must be defined as PIC S9(4) COMP.
If the column value IS NOT NULL, the value of HOST-NULL-IND = 0, if the column value IS NULL, the value of HOST-NULL-IND = -1.
Your program must be coded to look at this field and act appropriately.
Now, if you want the null value to default, there is another way to handle this.
SELECT COALESCE (COLUMN_VAR, 0),
Assuming that COLUMN_VAR if declared as numeric, the COALESCE function returns the first NON NULL value it encounters in the argument list. In the case above, it would return 0 (zero).
All times are GMT + 6 Hours