Stage Variables and SetNull()

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
russ356
Charter Member
Charter Member
Posts: 38
Joined: Tue Jun 07, 2005 6:58 am

Stage Variables and SetNull()

Post by russ356 »

I have a weird problem here that I just can't figure out. Below is the code for a stage variable that is returning a wrong value.

stgExpectedReturnDate: If LU_BC_xref_lnk.ACTION="LOA" Then stgExpReturnDt Else SetNull()

When the code executes it returns null but for some reason in the output of the field it is using the value that was last calculated for stgExpectedReturnDate.

Case Action Expected Return Date
1 LOA 09/01/2008
2 HIR NULL
3 XFR NULL


Output
Case Action Expected Return Date
1 LOA 09/01/2008
2 HIR 09/01/2008
3 XFR 09/01/2008

Obviously this only occurs if there is an action of LOA in the dataset and if I run the data through by itself it calculates fine. I am lost and don't know where to look.
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post by OddJob »

I have seen this exact problem.

Unfortunately you can't store NULL in a stage variable, it just isn't supported. You shouldn't be able to use functions like SetNull in the stage variables, but a bug in DS allows it in this case as part of an 'if' statement.

Try creating a stage variable with just SetNull() as its derivation and it'll fail to compile. If you use the 'More' button you can view the C++ code generated, and see that it will in no way work with Nulls - it seems to make a vain attempt with a variable called 'NullSetVar0'.
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post by OddJob »

And if you do use 'Null' functions the output is very erratic!
Post Reply