IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Load NULLS to this date field in DB2


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
candyboy

New User


Joined: 13 Nov 2006
Posts: 10

PostPosted: Tue Jan 06, 2009 8:24 am
Reply with quote

Hi,

I have a field defined as X(10) in which i normally store a date like '2009-01-01'. This field corresponds to a DATE (DB2 datatype DATE) field in DB2 table. I basically load my X(10) field to this DATE field in DB2.

I have a requirement now to load NULLS to this date field in DB2. Could you let me know what should I move in the X(10) field to achieve nulls in the date field on table. Or if there is some other way to do it....let me know.

Thanks!!
CB
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jan 06, 2009 8:46 am
Reply with quote

Hello,

If there is still time, i would suggest that you not use NULL. . . It may well be that others in your organization are not familiar with NULL also.

There is no actual "null" value - NULL is the absence of any value. When using NULL, a column needs 2 host variable entries - one for the actual value of the data and the other to indicate whether there is a value or not. This is known as the NULL indicator.

Suggest you talk with your dba for some samples of other tables/columns that are defined as NULLable and the code used to select/insert/update them if NULL must be used.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Jan 06, 2009 10:38 am
Reply with quote

Hi,

Will these work?

1. Just omit date field while inserting...

2. Use NULL while inserting...

Sorry, I'm not sure if this suits for your requirement. icon_sad.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jan 06, 2009 6:01 pm
Reply with quote

Is the column in the DB2 table defined as nullable. If it is then just set the null indicator to -1 when you do an insert.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jan 06, 2009 6:46 pm
Reply with quote

candyboy,

Do you use some LOAD utility to achieve this?
I believe the BMC LOADPLUS has some option to load the column as NULL if the value in the file equals ' '(space) or some constant.
Back to top
View user's profile Send private message
candyboy

New User


Joined: 13 Nov 2006
Posts: 10

PostPosted: Tue Jan 06, 2009 7:58 pm
Reply with quote

Hi All,

Yes the field is defined as nullable in the table and under normal circumstances, the null indicator is used with value -1 while writing the field to table. This is when we use proper modules & view handlers.

But currently we are loading table using a load file. We are using DSNUTILB for loading.

The issue we have rite now is:
I have a table with fields say A,B,C &D where C being the nullable Date field.
To load this table we are creating a load file with fields A,B,C & D.

Now if I accomodate a Null indicator in my load file (A,B,C,C-NI,D) , the length of my load file increases and this pushes the remaining fields further causing load to fail.

Thanks
CB
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 06, 2009 8:31 pm
Reply with quote

have you thought of modifiying the mask definition to accomodate the extra length in the input record length?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jan 06, 2009 8:36 pm
Reply with quote

Put the null indicator after the last field or use the first byte of the date field to indicate that it should be null. Or change your load control cards which you would have to do anyways!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts How to load to DB2 with column level ... DB2 6
Search our Forums:

Back to Top