How does the decode function work (Legacy KB ID CNC TS12283 )

Document ID : KB000052527
Last Modified Date : 14/02/2018
Show Technical Document Details
Starting with eHealth 5.x, eHealth has built in defensive code because expressions of the form x/y might result in a division by zero, CA recommends that you rewrite these expressions to use the decode statement if you have made any modifications to them. The decode statement takes any expression of the form x/y, and if y (the divisor) is equal to zero, the expression is equal to zero. If y is not zero, the expression is evaluated. The format for the decode statement is:

DECODE(y, match_value, match, x/y) where:
if y = match_value, then the expression evaluates to match, or
if y does not equal match_value, then the expression is evaluated.

For example, the expression TR_CONTENTION_STREAMING/DELTA_TIME*100 should be converted to DECODE(DELTA_TIME, 0, 0, TR_CONTENTION_STREAMING/DELTA_TIME*100).

You need to delete the INTEGER4 construct and the FLOAT4 construct from expressions that contain those constructs. For example, the expression FLOAT4(TR_CONTENTION_STREAMING)/FLOAT4(TR_BIT_STREAMING) should be converted to TR_CONTENTION_STREAMING/TR_BIT_STREAMING.

CA has reviewed the columnExpression.sys file for expressions that contain INTEGER4 and FLOAT4 and expressions of the form, x/y, and made the necessary modifications.

Related Issues/Questions:
what does decode mean in the following expression
What does the decode statement mean in the columnExpression.sys file
What does the decode statement mean in the element variable report
How does the decode function work

Problem Environment:

(Legacy KB ID CNC TS12283 )