top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Case Statements/Decode Function in Informatica

+1 vote
1,617 views

Could anyone help me with writing case statements in Informatica PowerCenter Designer? I am fairly new to Informatica, and based on my limited experience I feel case statements aren't supported. There is a decode function with similar functionality, but I am unable to find any good examples on the syntax.

I would really appreciate if anyone could give me some specific examples on how to use case statements/decode function in Informatica.

Thanks much for your help!

posted Apr 11, 2014 by Rohini Agarwal

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

0 votes

You're right - there is no CASE statement, but you can use DECODE to simulate it:

DECODE( TRUE
      , DECIMAL_PORT > 0, 'positive value'
      , DECIMAL_PORT < 0, 'negative value'
                        , 'zero' )

It is an equivalent of the following Transact-SQL CASE statement:

CASE
  WHEN DECIMAL_PORT > 0 THEN 'positive value'
  WHEN DECIMAL_PORT < 0 THEN 'negative value'
  ELSE 'zero'
END

Here's how it works:
•The 1st parameter is a hard-coded TRUE value,
•Even parameters (2nd, 4th and so on) are the conditions,
•Odd parameters (3rd, 5th and so on) are the return values,
•The last parameter is the default return value,
•The first condition that evaluates to the value of the 1st parameter (i.e. the first condition that is true) determines the value that is returned,
•If none of the conditions is met the last parameter is returned

answer Apr 15, 2014 by Shweta Singh
0 votes

We can use IIF() function to implement conditional logic:
IIF(DECIMAL_PORT > 0, 'positive value', IIF(DECIMAL_PORT < 0 ,'negative value', 'zero'))

NOTE: If conditions are less then we can use IIF() function, if there are many condition then we can use Decode function explained below.

answer Jun 12, 2014 by Shatark Bajpai
Similar Questions
+2 votes

I'm new to Informatica and like to ask a question regarding infa ports. I found an example which show how to create an update flag in expression transform for updating data. The code in v_UPDATE_FLAG port looks like this:

IIF(NOT ISNULL(PREV_ITEM_KEY)
AND
(
DECODE(BONUS_FLAG,PREV_BONUS_FLAG,1,0) = 0 
OR
DECODE(DISCOUNT,PREV_DISCOUNT,1,0) = 0 
OR
DECODE(PRICE,PREV_PRICE,1,0) = 0 
),'TRUE','FALSE'

)

Can anyone explain what this does? What the DECODE does here??

DECODE(BONUS_FLAG,PREV_BONUS_FLAG,1,0) = 0 
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...