Transformer Constraint

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
shravya346
Participant
Posts: 9
Joined: Wed Dec 07, 2011 3:01 pm
Location: SEATTLE

Transformer Constraint

Post by shravya346 »

Can i write multiple conditions in constraint in transformer .

example :

link2.custid<>'1253' or link2.custid<>'4859'


when i write like this the filter is not being applied when i use only one condition like

link2.custid<>'1253' then its working fine .

What is the mistake in this and can you help me with the syntax
jhmckeever
Premium Member
Premium Member
Posts: 301
Joined: Thu Jul 14, 2005 10:27 am
Location: Melbourne, Australia
Contact:

Post by jhmckeever »

To apply one constraint AND another constraint you should use an AND clause between the conditions! :-)
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
Sivacharan Irukulla
Premium Member
Premium Member
Posts: 5
Joined: Mon Apr 09, 2012 8:44 am
Location: Chennai

Post by Sivacharan Irukulla »

I am wondering in which case your condition will fail.

Let us take one positive and one negitive scenario, assuming the input data is as expected.

If the input Custid ='1253' then Condition one fails and condition 2 pass so the result is fail or pass = pass.

If the input Custid ='4859' then Condition one pass and condition 2 fails so the result is pass or fail = pass.


If the input Custid ='1111' then Condition one pass and condition 2 pass so the result is pass or pass = pass.

Hope the logic is wrong.

Its better practice to use the Trim function while using the char fields in conditions.
Always check the input data should not have junk values which can occur while conversion of varchar to char :shock:
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

You are facing a logic problem (logic as in TRUE/FALSE, ANDs and ORs). A constraint must evaluate to TRUE in order for a row to be written to the link, and must evaluate to FALSE in order for a row to NOT be written to the link.

You provided the following logic:

Code: Select all

link2.custid<>'1253' or link2.custid<>'4859' 
Under what conditions will it evaluate to FALSE? Both of the comparisons must evaluate to FALSE in your logic. Can that happen?

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Yes, you can have many conditions using Or, And, or both. As mentioned, you've used an Or when you most likely should have used an And. Your syntax is correct. Add parenthesis to help group them if you have many, just like any programming language.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Post Reply