Expression Passed as Job Parameter is not working

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
DS4DRIVER
Premium Member
Premium Member
Posts: 39
Joined: Thu Oct 30, 2003 1:37 pm

Expression Passed as Job Parameter is not working

Post by DS4DRIVER »

I have prepared an Expression via Unix script (dynamic in nature based on the number of records in a table that drives the expression) that needs to be used in the Transformer Stage of a job. This expression does not return the result that i am looking for, instead, just outputs the expression itself.

In the Transformer Stage i have the following Stage Variables.
lnk_ALLFIELDS.DOLLAR_VAL --> svDollarValue (Where DOLLAR_VAL is the Input Column in link lnk_ALLFIELDS)
WGHT_EXPRESSION --> svWeight (Where WGHT_EXPRESSION is the Job Parameter).

The Run Time value of WGHT_EXPRESSION is: If (svDollarValue > 1000000 And svDollarValue < 1000000000) Then 100 Else If (svDollarValue > 100000 And svDollarValue < 999999) Then 30 Else If (svDollarValue > 50000 And svDollarValue < 99999) Then 20 Else If (svDollarValue > 30000 And svDollarValue < 49999) Then 10 Else If (svDollarValue > 10000 And svDollarValue < 29999) Then 5 Else If (svDollarValue > 1000 And svDollarValue < 9999) Then 0 Else 0

I was thinking that svDollarValue in the expression would be replaced by the value of Stage Variable svDollarValue. But, i do not see this happening.

When i capture output of svWeight to a Output Column and view the result, it just consists of the Expression that was passed (If (svDollarValue > 1000000 And svDollarValue < 1000000000) Then 100 Else If (svDollarValue > 100000 And svDollarValue < 999999) Then 30 Else If (svDollarValue > 50000 And svDollarValue < 99999) Then 20 Else If (svDollarValue > 30000 And svDollarValue < 49999) Then 10 Else If (svDollarValue > 10000 And svDollarValue < 29999) Then 5 Else If (svDollarValue > 1000 And svDollarValue < 9999) Then 0 Else 0)

Ex:
If lnk_ALLFIELDS.DOLLAR_VAL --> svDollarValue = 2073522
Since svDollarValue falls in the range (svDollarValue > 1000000 And svDollarValue < 1000000000) Then 100, i was expecting the output to be 100.

But, the conditional expression does not execute (in other words, it does not use svDollarValue Stage Variable).

Is there a way to make this work?

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, but that's not going to work. It won't do the multiple 'levels' or iterations of substitution / resolution you're looking for. It does turn your job parameter into the string you passed in but it's just a string at that point, it doesn't then know it then needs to resolve the stage variables. It's the same issue people find when they put a job parameter's #name# inside another job parameter's value. :(
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Is the If-Then-Else combination be the same always with with different range checks?

Alternatively use server jobs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

'Alternately use Server jobs' how? This isn't a problem just for PX, hence the question.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

EVAL should do the trick.
DS4DRIVER
Premium Member
Premium Member
Posts: 39
Joined: Thu Oct 30, 2003 1:37 pm

Post by DS4DRIVER »

The If Else statement is prepared by reading a Table. The number of ranges vary. Today the number of ranges can be 5, tomorrow 6 etc. So, using a Unix script, i prepare this Statement and Pass it to the Job. But, i was not sccessful of what i thought.

Any Ideas?

Thanks.
DS4DRIVER
Premium Member
Premium Member
Posts: 39
Joined: Thu Oct 30, 2003 1:37 pm

Post by DS4DRIVER »

If I have to use EVAL where do i use it?

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't see how it would help at all.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply