Case Statements/Decode Function in Informatica

泪湿孤枕 提交于 2019-12-12 09:34:57

问题


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!


回答1:


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.



回答2:


Look also at the IIF() function which is often used to implement conditional logic:

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


来源:https://stackoverflow.com/questions/9979163/case-statements-decode-function-in-informatica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!