Page 1 of 1

Transformer Constraint

Posted: Tue Apr 10, 2012 2:46 pm
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

Posted: Tue Apr 10, 2012 3:54 pm
by jhmckeever
To apply one constraint AND another constraint you should use an AND clause between the conditions! :-)

Posted: Tue Apr 10, 2012 3:55 pm
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:

Posted: Tue Apr 10, 2012 3:56 pm
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,

Posted: Tue Apr 10, 2012 5:25 pm
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.