Both CASE and DECODE function as IF-THEN-ELSE statements:
(limit your conversions to SQL statements in Oracle only)
CASE
WHEN THEN
ELSE
END
converts to:
DECODE(, , , )
and
DECODE(, , , , , )
converts to:
CASE
WHEN THEN
WHEN THEN
ELSE
END
Login to rate this answer.
Sorry about that seems some of the info got stripped out of my examples, so once again:
CASE "expression"
WHEN "search condition 1" THEN
"return value 1"
ELSE
"return else value"
END
converts to:
DECODE("expression", "search condition 1", "return value 1", "return else value")
and
DECODE("expression", "search condition 1", "return value 1", "search condition 2", "return value 2", "return else value")
converts to:
CASE "expression"
WHEN "search condition 1" THEN
"return value 1"
WHEN "search condition 2" THEN
"return value 2"
ELSE
"return else value"
END
Login to rate this answer.