Why you should care
expression – The value to compare
search – The value is compared against expression
result – The value returned, if expression is equal to search
default – Optional. If not matches are found, the DECODE function will return default. If default is omitted, then the DECODE function will return null (if no matches are found).
With that being said, CASE is a better function as it is simpler to write and can be used in PL/SQL. CASE is easier to read, understand and maintain the code.
DECODE function is an old function replaced by CASE because the latter is less risky to use and more productive. This is because CASE is easier to read, understand and maintain.
How we detect
This code insight shows that DECODE is an old function that has been replaced by the easier-to-understand and more common CASE function. Contrary to the DECODE statement CASE may also be used directly within PL/SQL
About CAST and Highlight’s Code Insights
Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.