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

How to specify NULLIF for a decimal column in DB2 Load JCL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Tue Jan 08, 2008 9:10 pm
Reply with quote

I want to load a DB2 table with a null value for a decimal column on it.

In the Load JCL,can we use the NULLIF statement to populate NULL value for a decimal field.
If yes,Please help me with the format of the statement.

Thanks
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 08, 2008 9:57 pm
Reply with quote

mfstudent1 wrote:
I want to load a DB2 table with a null value for a decimal column on it.

In the Load JCL,can we use the NULLIF statement to populate NULL value for a decimal field.
If yes,Please help me with the format of the statement.

Thanks


Is the column defined as nullable?
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Tue Jan 08, 2008 10:01 pm
Reply with quote

icon_cool.gif

Yes it is defined as a Nullable column
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 08, 2008 10:11 pm
Reply with quote

How are going to tell when the column is null and when it is not? That is the condition you need to enter in the NULLIF statement.
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Tue Jan 08, 2008 10:15 pm
Reply with quote

Thanks for the update.

But i wanted to know how to use the NULLIF statement for a decimal column.
I have used nullif for other data types.But decimal field is always a comp-3 field.
How shud I specify the attributes?
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 08, 2008 11:04 pm
Reply with quote

mfstudent1 wrote:
Thanks for the update.

But i wanted to know how to use the NULLIF statement for a decimal column.
I have used nullif for other data types.But decimal field is always a comp-3 field.
How shud I specify the attributes?


If the column is null for a row then there is no value for that column in that row just a null indicator with a -1 value.
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Tue Jan 08, 2008 11:35 pm
Reply with quote

I want to populate the Null value using a load jcl.
I just wanted to know how to use nullif condition for comp-3 field
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 08, 2008 11:45 pm
Reply with quote

mfstudent1 wrote:
I want to populate the Null value using a load jcl.
I just wanted to know how to use nullif condition for comp-3 field

You use the NULLIF condition for a decimal column the same as you would for any other column.
Column definition
Code:
TOT_NSW_DOLLARS                 DEC(7,2),


then the load would be
Code:
"TOT_NSW_DOLLARS   " POSITION(  00603:00611) DECIMAL EXTERNAL(09,02) NULLIF(00602)=X'FF',


What don't you understand?
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Wed Jan 09, 2008 12:09 am
Reply with quote

Thanks a lot for the response.

I will try this and let you know the update...
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 09, 2008 1:10 am
Reply with quote

mfstudent1: Based on what Craq Giegerich said, you need to ensure that you have a byte before your field that is set to x'FF' if you want a NULL. It won't matter what the value of the actual field is then.
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Wed Jan 09, 2008 1:20 am
Reply with quote

But i want to check the actual value in comp-3 field and then populate a null for the column
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Jan 09, 2008 1:37 am
Reply with quote

mfstudent1 wrote:
But i want to check the actual value in comp-3 field and then populate a null for the column


I will ask AGAIN. How are you going to determine if the field is going to be null? And what is the format of the field?
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 09, 2008 1:42 am
Reply with quote

If the value is stored comp-3 it should be a valid numeric, why NULL the DB column when you have a valid value?

Do you want NULL if that value is negative or 0 or 12.789889? What is the rule for NULLING?
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Wed Jan 09, 2008 1:50 am
Reply with quote

My question is straight forward.

is there a way to populate a null value in the decimal column.I don't want to use another field value to populate null value in this field.

I hope iam clear
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 09, 2008 1:56 am
Reply with quote

Your question is far from straight forward.

To answer your "straight forward question", yes there is a way to populate a NULL value in a decimal column.

However you are also saying you want to populate based on a 'comp-3' field in a file. By saying 'based on', you are implying that you are using some value to determine whether or not a NULL needs to be inserted. NULLIF requires some sort of conditional check, hence the "IF" part of the statement.

What do you want to check to determine whether or not the NULL is to be inserted? The value in the COMP-3? If so what cases will result in a NULL being inserted?
Do you want every row to have a NULL for that column? This is far easier to accomplish because no NULLIF is needed, just specify NULL for that column.
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Wed Jan 09, 2008 2:04 am
Reply with quote

Thanks for the update.

Can I always populate a null value for nullable column which is a decimal one.Here I dont want to check the data in the field .I Just want to populate a null value always
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 09, 2008 2:07 am
Reply with quote

Have you tried coding NULLIF (1=0)
Back to top
View user's profile Send private message
mfstudent1
Currently Banned

New User


Joined: 03 Mar 2006
Posts: 18

PostPosted: Wed Jan 09, 2008 2:09 am
Reply with quote

Wat do you mean by (1=0) here?
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 09, 2008 2:11 am
Reply with quote

Whoops that should be NULLIF(1=1) since that will always be true or maybe NULLIF(TRUE) or have the DBA set the column to have a default value of NULL when a value is not provided.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Jan 09, 2008 2:26 am
Reply with quote

If you want every row to be null in that column then don't even have it in the load!
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 09, 2008 2:28 am
Reply with quote

If the column isn't wasn't created to have a default of NULL (can you even do that) don't you need to specify it still as part of the load?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Jan 09, 2008 2:50 am
Reply with quote

stodolas wrote:
If the column isn't wasn't created to have a default of NULL (can you even do that) don't you need to specify it still as part of the load?


If the column is nullable then the default is NULL.
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Load new table with Old unload - DB2 DB2 6
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts REASON 00D70014 in load utility DB2 6
Search our Forums:

Back to Top