Page 1 of 1
IF THEN ELSE
Posted: Tue Sep 01, 2009 9:54 am
by kkumardatastage
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
Posted: Tue Sep 01, 2009 10:01 am
by Sainath.Srinivasan
You appear to be a registered member for an year now.
Why don't you give it a shot and others will help if necessary !?
Posted: Tue Sep 01, 2009 3:17 pm
by RAJARP
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
Posted: Tue Sep 01, 2009 10:51 pm
by laknar
Stage Variable1
-------------------------
Code: Select all
IF IsNull(ColumnA) Then '0' Else If (ColumnA='O13' or ColumnA='S10' ) and ColumnB>0 Then ColumnB Else '0'
Stage Variable2
-------------------------
Code: Select all
IF IsNull(ColumnA) Then '0' Else If (ColumnA='O13' or ColumnA='S10' or Trim(ColumnA='')) Else '0'
Have Constraint in transformer
Stage Variable1<>'0' or Stage Variable1<>'0'
For derivations just substitute the stage variable for the respective columns
Posted: Tue Sep 01, 2009 11:07 pm
by chulett
Missing the 'then' from sv2.
Posted: Tue Sep 01, 2009 11:20 pm
by chulett
svColumnAisValid:
Code: Select all
Link.ColumnA = 'O13' Or Link.ColumnA = 'S10' Or Link.ColumnA = ' '
Assuming you mean literally *a* space. You may need to throw a Trim() into the last check if not.
svColumnBisValid:
Code: Select all
Num(Link.ColumnB) And ((Link.ColumnB > 0 And (Link.ColumnA = 'O13' Or Link.ColumnA = 'S10')) Or Link.ColumnB <= 0)
Constraint derivation to pass only valid rows:
Code: Select all
svColumnAisValid And svColumnBisValid
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:
Code: Select all
Num(Link.ColumnB) And ((Link.ColumnB > 0 And svColumnAisValid) Or Link.ColumnB <= 0)
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.
Posted: Tue Sep 01, 2009 11:31 pm
by laknar
Sorry
Code: Select all
IF IsNull(ColumnA) Then '0' Else If (ColumnA='O13' or ColumnA='S10' or Trim(ColumnA='')) Then ColumnA Else '0'