Oracle Decode Function.

One Star

Oracle Decode Function.

Bonjour,
I'm new to TOS.
How can I achieve the equivalent of Oracle's Decode Function within tMap? What is the best way to achieve this in TOS?
Thanks.
PM
Community Manager

Re: Oracle Decode Function.

Hello
How can I achieve the equivalent of Oracle's Decode Function within tMap? What is the best way to achieve this in TOS?

Type in the code below in expression filed of tMapSmiley Sadfor example)
row1.supplier_id==1?value1:(row1.supplier_id==2?value2:value3)

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Employee

Re: Oracle Decode Function.

Or in Perl:
$row1 == 1
? 'value1'
: $row1 == 2
? 'value2'
: 'other'
Five Stars

Re: Oracle Decode Function.

How can I used following condition in TOS
IIF(upper(STANDING_TAX)= 'GOOD' AND upper(STANDING_RA) = 'GOOD' AND upper(STANDING_OTHER) = 'GOOD' ,'1','2')
I have output field GOODSTD, but I want to check with 3 fields which are shown in above condition.
Community Manager

Re: Oracle Decode Function.

Hi rahul.nawale
If I understand you correctly, the original expression indicates the result will be "1" if all of the three conditions match, otherwise, it is "2", right?
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: Oracle Decode Function.

yes shong. You are right.
One Star

Re: Oracle Decode Function.

Hi... If you're doing this in tMap which accepts only ternary operators, it'd be:
STANDING_TAX.toUpperCase().equals("GOOD") && STANDING_RA.toUpperCase().equals("GOOD") && STANDING_OTHER.toUpperCase().equals("GOOD") ? "1" : "2"
If in tJava that accepts regular if-then-else, it'd be:

String STANDING_TAX = "";
String STANDING_RA = "";
String STANDING_OTHER = "";
String Output = "";
if (
STANDING_TAX.toUpperCase().equals("GOOD") && STANDING_RA.toUpperCase().equals("GOOD") &&
STANDING_OTHER.toUpperCase().equals("GOOD")
)
{
Output = "1";
}
else
{
Output = "2";
};
System.out.println("Output is... " + Output);
Five Stars

Re: Oracle Decode Function.

Thanks willm, its working.
One Star

Re: Oracle Decode Function.

Glad to hear... Smiley Happy