IF THEN ELSE

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kkumardatastage
Participant
Posts: 84
Joined: Sat Jul 19, 2008 8:50 am

IF THEN ELSE

Post 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
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post 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 !?
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

Post 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
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Missing the 'then' from sv2.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post 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'
Post Reply