Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

what to do to handle null values?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
niharika1234

New User


Joined: 01 May 2006
Posts: 9

PostPosted: Thu Aug 03, 2006 12:07 pm    Post subject: what to do to handle null values?
Reply with quote

Hi all,

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
Back to top
View user's profile Send private message

vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Thu Aug 03, 2006 12:27 pm    Post subject:
Reply with quote

Please Use below code like this


*
FETCH-para1


EXEC SQL
FETCH CURSR01
INTO
icon_biggrin.gifB-DATABASE-ROW-READ
icon_biggrin.gifB-ROW-READ-NULL.NUL-IND
END-EXEC.
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Thu Aug 03, 2006 2:17 pm    Post subject: Re: what to do to handle null values?
Reply with quote

hi niharika1234,

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......

EXEC SQL
FETCH CURSR01
INTO
DATABASE-VARIABLE :DATABASEVARIABLE-ID(null indicator)
,..........
END-EXEC.


~Vamsi
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Aug 04, 2006 5:10 am    Post subject:
Reply with quote

Hi niharika1234,

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:

Code:

  SELECT COLUMN_VAR,
    :
    INTO :HOST-VAR:HOST-NULL-IND,
    :


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.

Code:

  SELECT COALESCE (COLUMN_VAR, 0),
    :
    INTO :HOST-VAR
    :


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).

Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us