Search notes:

Oracle SQL: DECODE

DECODE( expr
        val_1 , result_1 ,
        val_2 , result_2 ,
        val_3 , result_3 ,
)
Decode compares the value of expr with val_n and returns result_n for the first val_n that is equal to expr.

Default value

It's possible to add a default value which is returned if no values match:
DECODE( expr
        val_1 , result_1 ,
        …
        default_value
)

Special NULL treatment

decode compares null values differently than one is used to from Oracle in that decode considers null to be equal to null.
The following statement returns 42:
select
   decode( null ,
      null,  42,
     'xyz',  99,
             17)
from
   dual;

See also

The SQL Server equivalent for decode seems to be choose.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758191574, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQL/functions/decode(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78