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.
Stage Variables and SetNull()
Moderators: chulett, rschirm, roy
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'.
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'.