DECODE is a single-row function in Oracle, which applies conditional logic to SQL queries. This function works very much like an IF-THEN-ELSE statement.


  DECODE (expression1,
            value1, return_value1,
            value2, return_value2,
            valueN, return_valueN,

How it works

If expression1 equals value1 then return_value1 is returned by DECODE function, and if expression1 equals value2 then return_value2 is returned and so on…..

The optional default_return_value is returned if expression1 does not match with any of (value1, value2, ..., valueN).

In short

IF expression1 = valueN   THEN return_valueN  ELSE default_return_value


 DECODE (day_id,
                '1', 'Monday',
                '2', 'Tuesday',
                '7', 'Sunday',
                     'Not Valid')

Search another word or see decodeon Dictionary | Thesaurus |Spanish
Copyright © 2015, LLC. All rights reserved.
  • Please Login or Sign Up to use the Recent Searches feature