Nulls in stage variables become 0/empty string in output

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
JeroenDmt
Premium Member
Premium Member
Posts: 107
Joined: Wed Oct 26, 2005 7:36 am

Nulls in stage variables become 0/empty string in output

Post by JeroenDmt »

When I try to set a stage variable to a NULL value using SetNull(), and I use this stage variable in an output derivation for a nullable field, the output becomes 0 (integer field) or an empty string (string field).

For example if I have
- an integer stagevariable svar defined as '

Code: Select all

if 1=1 then SetNull() else SetNull()
'
- two nullable integer outputfields:
- f1: defined as

Code: Select all

svar
- f2: defined as

Code: Select all

if 1=1 then SetNull() else SetNull()
(same expression as for svar).

I would expect the result for both integer fields to be NULL.
However the output for f1=0, for f2 it is NULL.

Can a stage variable not be NULL, or what is my problem?
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Re: Nulls in stage variables become 0/empty string in output

Post by G SHIVARANJANI »

Try to set the stage variable properties.
Shivaranjani
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

check the properties of stage variables which should solve the issue.
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

Stage variables are non-nullable.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

If stage variable property is non-nullable then we should not assign any null value to the stage variable. If we do we get a default value of 0.
JeroenDmt
Premium Member
Premium Member
Posts: 107
Joined: Wed Oct 26, 2005 7:36 am

Post by JeroenDmt »

Raghavendra wrote:check the properties of stage variables which should solve the issue.
..
If stage variable property is non-nullable then we should not assign any null value to the stage variable. If we do we get a default value of 0.
You make it sound like there is a property you can set to make a stage variable nullable. I can't find anything like that though.

So I assume battaliou is right and stage variables are always non-nullable indeed.
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

Yes stage variables are always not nullable and so we cannot use setnull function in the stage variable. Sorry for creating the confusion.
Post Reply