The Oracle DECODE function lets you perform IF-THEN-ELSE functionality in your queries. It’s similar to a CASE statement.
The syntax of the DECODE function is:
DECODE ( expression, search, result [, search, result]... [,default] )
The parameters of the Oracle DECODE function are:
- expression (mandatory): This is the value to compare.
- search (mandatory): This is the value to compare against the expression.
- result (mandatory): This is the return value if the search value matches the expression value. There can be multiple combinations of search and result values, and the result value is attached to the previous search value.
- default (optional): If none of the search values match, then this value is returned. If this is not provided, the DECODE function will return NULL if no matches are found.
If you compare this to an IF-THEN-ELSE statement, it would look like this:
IF (expression = search) THEN result
[ELSE IF (expression = search) THEN result]
The parameters can be one of many different data types, and the return type is calculated from them.
Earlier I mentioned it’s similar to CASE. So why would you use one and not the other?
- DECODE is an older function, and CASE was introduced as a replacement for DECODE.
- CASE offers more flexibility then DECODE
- CASE is also easier to read and debug (in my opinion)
The performance of these functions is the same, so if you’re considering using DECODE, I would suggest using CASE instead.
For more information about the Oracle DECODE function, including all of the SQL shown in this video and the examples, read the related article here:
To the east is the entrance area to the vault. In order to open it, you have to work out how to open all of the doors at once. One of the instructions will open a door without closing any. This must be the last key you press. Now, find a way to open a door that closes only the doors you will open later. And continue until all of the doors are open.
One solution is "NILBOG". (Many other solutions are possible; this one has the advantage of spelling something interesting when reversed.) Each key opens a door while not closing any of the doors you have already opened.
Pushing the Mainentance button (M), will teleport you to caves underneath the castle. When you leave this area, it will open up a new door to the east of the entrance room.
At the very first intersection, to the right is a room. A chest in that room contains the candelabrum needed to solve quest 3.
Continuing down the corridor into the caverns, you will come to a room containing a chest in the middle of the room and a Spark spell containstly bashing down onto it. You can empty the chest by timing you steps correctly. Be careful, as the Spark spell seems to be a master level spark.
The next room and then north leads to where Angela is trapped. She will join your party automatically and you can return her to town to solve quest 6.
Further west and then back east, and then to the end of the passage is a teleporter that returns you to the room south of where you found Angela.
If you instead go further west is the lair of some cobras. You can find several cobra eggs scattered around this room.
To the south is the lair of the Queen of the Spiders. Kill her and you will find her heart. This will satisfy quest 4. There is also a teleporter here that will return you to the starting room.