It is not a question of which one is better, because they are mutualy exclusive.
DECODE is an SQL function that you can use only in an SQL DML statement, but you can't use it in an PL/SQL procedural construct (you can use it in an SQL statement inside the PL/SQL construct, but that is still SQL statement).
IF-ELSE-ENDIF on the other hand is a PL/SQL flow-controll structure that you can only use in a pure PL/SQL construct and can never be used inside any SQL statement.
I don't say that you can't sometime use a clever DECODE inside a SELECT in order to avoid unnecessary PL/SQL's IF-ELSE logic or vice versa, but you can't compare them in general as to which one is better. Comparing DECODE versus CASE yes, but DECODE versus IF-ELSE not.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Bookmarks