IF THEN ELSE
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 84
- Joined: Sat Jul 19, 2008 8:50 am
IF THEN ELSE
Pls can any one help me, i got This 2 following conditions must validate for Input data file.
1) Input column A Must be 'O13' or 'S10' or space else reject the column
2) Input column B Must be Numeric and If It is > 0 then the column A must be 'O13' or 'S10'
Input data file
---------------------------------------
Column A Column B
S10(datatype:char 00001(Decimal
Space 00000
what will be the 'if then else' condition we need to apply in transformer to Validate the 2 conditions
1) Input column A Must be 'O13' or 'S10' or space else reject the column
2) Input column B Must be Numeric and If It is > 0 then the column A must be 'O13' or 'S10'
Input data file
---------------------------------------
Column A Column B
S10(datatype:char 00001(Decimal
Space 00000
what will be the 'if then else' condition we need to apply in transformer to Validate the 2 conditions
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Hi,
Design a job like this
I/p file----->Transfomer------>target
|
|
Reject
In a transfomer define two stage variables
under stageVariable1, give this expression
If((LINK_NAME.ColumnA)='013' or (LINK_NAME.ColumnA)='S10' or (LINK_NAME.ColumnA)='') Then
'P'
else
'R'
under stageVariable2, give this expression
if ((NUM(LINK_NAME.COLB)<>'' and NUM(LINK_NAME.COLB)=1) then
(
if ((LINK_NAME.ColumnA)='013' or (LINK_NAME.ColumnA)='S10') Then
'P'
Else
'R'
)
Else
'R'
Pass the records which is satisfying the constraint
stageVariable1='P' and stageVariable2='P'
to the Target
and
Pass the records which is satisfying the constraint
stageVariable1='R' and stageVariable2='R' to the source.Try this.
PS:the link for Rejct should come from transfomer
Regards,
Raja R P
Design a job like this
I/p file----->Transfomer------>target
|
|
Reject
In a transfomer define two stage variables
under stageVariable1, give this expression
If((LINK_NAME.ColumnA)='013' or (LINK_NAME.ColumnA)='S10' or (LINK_NAME.ColumnA)='') Then
'P'
else
'R'
under stageVariable2, give this expression
if ((NUM(LINK_NAME.COLB)<>'' and NUM(LINK_NAME.COLB)=1) then
(
if ((LINK_NAME.ColumnA)='013' or (LINK_NAME.ColumnA)='S10') Then
'P'
Else
'R'
)
Else
'R'
Pass the records which is satisfying the constraint
stageVariable1='P' and stageVariable2='P'
to the Target
and
Pass the records which is satisfying the constraint
stageVariable1='R' and stageVariable2='R' to the source.Try this.
PS:the link for Rejct should come from transfomer
Regards,
Raja R P
Stage Variable1
-------------------------
Stage Variable2
-------------------------
Have Constraint in transformer
Stage Variable1<>'0' or Stage Variable1<>'0'
For derivations just substitute the stage variable for the respective columns
-------------------------
Code: Select all
IF IsNull(ColumnA) Then '0' Else If (ColumnA='O13' or ColumnA='S10' ) and ColumnB>0 Then ColumnB Else '0'
-------------------------
Code: Select all
IF IsNull(ColumnA) Then '0' Else If (ColumnA='O13' or ColumnA='S10' or Trim(ColumnA='')) Else '0'
Stage Variable1<>'0' or Stage Variable1<>'0'
For derivations just substitute the stage variable for the respective columns
svColumnAisValid:
Assuming you mean literally *a* space. You may need to throw a Trim() into the last check if not.
svColumnBisValid:
Constraint derivation to pass only valid rows:
Hmmm... not an if-then-else in sight as everything automagically evaluates to either true or false. Note that you could simplify the second check if the space was part of the equation:
Or I might change the first sv to not include the space and setup another one to include the first sv and the space check. Would read easier that way. Oh, and you could use IsValid() rather than Num() for that one part of the check.
Code: Select all
Link.ColumnA = 'O13' Or Link.ColumnA = 'S10' Or Link.ColumnA = ' '
svColumnBisValid:
Code: Select all
Num(Link.ColumnB) And ((Link.ColumnB > 0 And (Link.ColumnA = 'O13' Or Link.ColumnA = 'S10')) Or Link.ColumnB <= 0)
Code: Select all
svColumnAisValid And svColumnBisValid
Code: Select all
Num(Link.ColumnB) And ((Link.ColumnB > 0 And svColumnAisValid) Or Link.ColumnB <= 0)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Sorry
Code: Select all
IF IsNull(ColumnA) Then '0' Else If (ColumnA='O13' or ColumnA='S10' or Trim(ColumnA='')) Then ColumnA Else '0'