question regding if then else
Moderators: chulett, rschirm, roy
question regding if then else
Hi,
I have this question regding if then -else.
Can we acheive
if <condition>
then <expression1> <expression2>
else
<expression3><expression4>
end
i.e., performing multiple actions based on single condition checking.
Let me know if I am not clear.
Thanks
srikie
I have this question regding if then -else.
Can we acheive
if <condition>
then <expression1> <expression2>
else
<expression3><expression4>
end
i.e., performing multiple actions based on single condition checking.
Let me know if I am not clear.
Thanks
srikie
Sure... more like this is how I do it:
Code: Select all
if <condition> then
<expression1>
<expression2>
else
<expression3>
<expression4>
end
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
It's end elsechulett wrote:Sure... more like this is how I do it:
Code: Select all
if <condition> then <expression1> <expression2> else <expression3> <expression4> end
Code: Select all
if <condition> then
<expression1>
<expression2>
end else
<expression3>
<expression4>
end
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
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
It's end else
[/quote][/quote]
But I dont want to return any thing from <expression2> I mean based on that condition I want to increment the counter variable.
e.g., if var1=0 then
var2
count:=count+1
end
will that work I mean I dont know the assignment stmt for datastage.
Thanks
srikie
Code: Select all
if <condition> then
<expression1>
<expression2>
end else
<expression3>
<expression4>
end
But I dont want to return any thing from <expression2> I mean based on that condition I want to increment the counter variable.
e.g., if var1=0 then
var2
count:=count+1
end
will that work I mean I dont know the assignment stmt for datastage.
Thanks
srikie
The assignment statement is confusing.
You can also do C++ type assignments:
Assignment in BASIC is the same as a logical statement. Not like other langauges where x == 1 checks for equality and x = 1 is an assignment statement.
Code: Select all
x = 12
if x = 12 then
y = 1
z = 2
end else
y = 2
z = 3
end
Code: Select all
x =1
x += 5
* x now equals 6
x -= 1
* x now equals 5
x := 2
* x now equals 25 because it is the same as x = "2" : "5"
* : concatenates strings together
Mamu Kim
* is a comment line. Also BASIC if then else is different than one used in a transformation. In a transformation it is treated as a single line statement therefore there is no end like a multiple line if then else.
if x = 1 then 10 else 20
This will assign a 10 or 20 to column in a transform.
if x = 1 then 10 else 20
This will assign a 10 or 20 to column in a transform.
Mamu Kim
Yeh that what I wanted to know if we could use multiple stmts in derivation in transformer stage. And also I am talking abt Data Stage mvs so BASIC doesnt work in this case.kduke wrote:* is a comment line. Also BASIC if then else is different than one used in a transformation. In a transformation it is treated as a single line statement therefore there is no end like a multiple line if then else.
if x = 1 then 10 else 20
This will assign a 10 or 20 to column in a transform.
Srikie
Code: Select all
IF COND=1 THEN VAR+1
ELSE IF COND=2 THEN VAR+2
END
I mean instead of if then else. I want if then end, if then end.
Can I have more than two if stmts in one derivation.
Once again I am talking abt MVS edition of datastage.
Thanks
Srikie
In a mainframe job transformer derivation, the derivation is essentially a single statement. For IF-THEN-ELSE the format is:
You need to use a business rule stage to utilize multiple IF-THEN-ELSE statements for a single output column derivation. For example:
Mike
Code: Select all
IF <BooleanExpression> THEN <Expression1> ELSE <Expression2> END
Code: Select all
IF <Condition> THEN
SET <Var>= <Expression>;
END IF;
IF <Condition> THEN
SET <Var>= <Expression>;
END IF;
I cant use business rule stage, coz all my transformation is done in transformer stage , I just want a way to keep track of the number of invalid i/ps if I use business stage I would lose that information or else I have to move all transofrmations into business rule stage.
Neway Thanks once again.
Srikie
Neway Thanks once again.
Srikie
I'm not sure why you think you can't split the transformations between a transformer and a business rule stage. Both stage types can keep track of error counts and error types with stage variables, and both stage types can write error records to the same output. One stage type can pass its stage variable contents to the other stage via output columns (to enable total counts across both stages).
Mike
Mike