Issue with multiple IF's in a transformer derivation

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
vskr72
Premium Member
Premium Member
Posts: 128
Joined: Wed Apr 28, 2004 9:36 pm

Issue with multiple IF's in a transformer derivation

Post by vskr72 »

I am having issues with using multiple IF.THEN.ELSE conditions. Psl see below. I have 6 conditions to be tested in a single statement. I used a routing using a Begin..Case..END. Thsi worked good for few times. But all of a sudden the routine started giving errors in PROD server. When ever this happened, I had to promote the routine again. To prevent this in the future, I want to put it in a transformer derivation. When I put like this it gives me an error. Any help pls.

If (C_LINE=1) Then
'b'
if (C_LINE=2) then
'd'
end else
'f'
end
end


Thanks

Kumar
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Kumar,

You need to do something like this:

"If condition1 then 'result1' elseif condition2 then 'result2' else 'result3'
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
hsbc_ds_dev
Premium Member
Premium Member
Posts: 22
Joined: Tue Oct 31, 2006 5:16 pm

Post by hsbc_ds_dev »

"If condition1 then 'result1' elseif condition2 then 'result2' else 'result3'
Should be...
If condition1 then 'result1' else if condition2 then 'result2' else 'result3'
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Re: Issue with multiple IF's in a transformer derivation

Post by I_Server_Whale »

vskr72 wrote:I used a routing using a Begin..Case..END. Thsi worked good for few times.
Routines are always (most of the time) a better way to code than using multiple If..Then...Else statements. Can you post the routine you created and the objective?
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Re: Issue with multiple IF's in a transformer derivation

Post by narasimha »

vskr72 wrote:But all of a sudden the routine started giving errors in PROD server. When ever this happened, I had to promote the routine again.
What errors did you get? You could try and debug that.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Your syntax is wrong.

If (C_LINE=1) Then 'b' else if (C_LINE=2) then 'd' else 'f'
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your syntax is OK in a server routine, but not in an expression in a Transformer stage, which must be a single string.

There is never an End in a conditional expression.
There is no elseif statement in a conditional expression.

Your solution for an expression in a Transformer stage must be

Code: Select all

If (C_LINE=1) Then 'b' Else If (C_LINE=2) Then 'd' Else 'f' 
Note that "Else If" is two words. If you find it clearer, surround the nested conditional expression in unnecessary parentheses.

Code: Select all

If (C_LINE=1) Then 'b' Else (If (C_LINE=2) Then 'd' Else 'f')
Last edited by ray.wurlod on Fri Feb 02, 2007 2:49 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vskr72
Premium Member
Premium Member
Posts: 128
Joined: Wed Apr 28, 2004 9:36 pm

Thanks a lot

Post by vskr72 »

Ray,

Thanks a lot. It worked.

Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So you can mark the thread as resolved.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply