Hi,
How can i handle this condition in DS?
If (DSLink47.FACode = "11" OR DSLink47.FACode = "12" OR (DSLink47.FACode="13" AND DSLink47.SM_Code !="24" AND DSLink47.SM_Code !=@NULL)
"A"
Case (DSLink47.FACode = "14" OR (DSLink47.FACode="13" AND DSLink47.SM_Code ="24"))
"C"
End Case
Regards
Shiv
Help me on this to solve it
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
You can use a CASE statement if you move the statement into a routine and call that routine from your transformer. FACode and SM_Code would be inputs to the routine and "A" and "C" would be the return code. Use the Test button to test your code.
You need to have a CASE @TRUE statement that captures all combinations that are not "A" or "C".
You need to have a CASE @TRUE statement that captures all combinations that are not "A" or "C".
Code: Select all
BEING CASE
CASE (FACode = "11" OR FACode = "12" OR (FACode="13" AND SMCode !="24" AND SMCode !=@NULL)
Ans = "A"
Case (FACode = "14" OR (FACode="13" AND SMCode ="24")) THEN
Ans = "C"
CASE @TRUE
Ans = "?"
END CASE
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I don't believe that != is a valid operator in server job expressions. The only valid operators in DataStage BASIC for "not equal to" are
<>
><
NE
#
You are not permitted to test against @NULL. You must use the IsNull function.
Expressions do not support the CASE construct; in an expression you'll need nested If..Then..Else to achieve your aim. Or you can move the logic to a routine, as Vince suggested (though it's BEGIN CASE rather than BEING CASE!).
So, what you're left with is:(you must cover all possibilities)
Logic is evaluated purely left to right except where other precedence is specified by parentheses. That is, AND and OR have the same precedence.
<>
><
NE
#
You are not permitted to test against @NULL. You must use the IsNull function.
Expressions do not support the CASE construct; in an expression you'll need nested If..Then..Else to achieve your aim. Or you can move the logic to a routine, as Vince suggested (though it's BEGIN CASE rather than BEING CASE!).
So, what you're left with is:
Code: Select all
If (DSLink47.FACode = "11" OR DSLink47.FACode = "12" OR (DSLink47.FACode="13" AND DSLink47.SM_Code <>"24" AND Not(IsNull(DSLink47.SM_Code)) Then "A" Else If (DSLink47.FACode = "14" OR (DSLink47.FACode="13" AND DSLink47.SM_Code ="24")) Then "C" Else ""
Logic is evaluated purely left to right except where other precedence is specified by parentheses. That is, AND and OR have the same precedence.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Are you sure about that, Ray? I was under the impression that it followed more 'standard' precedence rules in that AND had precedence over OR.ray.wurlod wrote:That is, AND and OR have the same precedence.
![Confused :?](./images/smilies/icon_confused.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Yes I'm sure (in DataStage BASIC and UniVerse BASIC expressions). Which is why I made the point - it's different from some other languages in this behaviour. :D
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
I sure am glad this wasn't a question in a DataStage certification test. I think I scored about 15%! I'd certainly put something like this in a routine so I could test it and add some code comments. You might find yourself using it in other jobs.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: