StageVariables:Null handling

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
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

StageVariables:Null handling

Post by Aquilis »

all,

i'm using two stagevariables as mentioned below.
Stagvar1:
If ((IsNotNull(Column1)) or (IsNotNull(Column2)) Then '0' Else '-100'

Stagvar2:
If (IsNull(Column3)) Then '-Z' Else (If (IsValid('Date', StringToDate(Column3,"%yyyy%mm%dd"))) Then '0' Else '-200')


stagvar3:
If stagvar1<>0 Then stagvar1 Else If stagvar2<>0 Then stagvar2 Else'1'

when i validate more than one Columns in the Stagvar1: its Not producing expected result.If i validate only single column then its ok.I dont understand whats happening.I think its not supporting 'OR' statement itself.Everytime i am getting return value as '1',when i pass Null value into Column1 or Column2. what would be the problem. Suggest.
Aquilis
Havoc
Participant
Posts: 110
Joined: Fri Nov 24, 2006 8:26 am

Re: StageVariables:Null handling

Post by Havoc »

Aquilis wrote:all,

i'm using two stagevariables as mentioned below.
Stagvar1:
If ((IsNotNull(Column1)) or (IsNotNull(Column2)) Then '0' Else '-100'

Stagvar2:
If (IsNull(Column3)) Then '-Z' Else (If (IsValid('Date', StringToDate(Column3,"%yyyy%mm%dd"))) Then '0' Else '-200')


stagvar3:
If stagvar1<>0 Then stagvar1 Else If stagvar2<>0 Then stagvar2 Else'1'

when i validate more than one Columns in the Stagvar1: its Not producing expected result.If i validate only single column then its ok.I dont understand whats happening.I think its not supporting 'OR' statement itself.Everytime i am getting return value as '1',when i pass Null value into Column1 or Column2. what would be the problem. Suggest.
Didnt quite understand what you meant by 'validate more than one Columns'.

You have specified an Or condition in your first stage variable which will produce the following results :

Column1 = NULL,Column2 = <non null value>, return value = 1
Column1 = <non null value>,Column2 = NULL , return value = 1
Column1 = NULL,Column2 = NULL , return value = 0
Column1 = <non null value>,Column2 = <non null value> , return value = 1

I am not sure about your business requirement but maybe changing that 'Or' to 'And' should address your concern which will return a 1 only if both columns have a non null value.
Post Reply