This script returns 2:
DECODE is internally implemented using Item_func_case, which treats two NULL values as not equal, so therefore the default value 2 is returned.
Oracle database works differently:
In a DECODE function, Oracle considers two nulls to be equivalent. If expr is null, then Oracle returns the result of the first search that is also null.
The above query returns 1 in Oracle:
This script demonstrates the same problem, now using a table column instead of an explicit NULL literal:
Oracle database returns:
DECODE should be fixed to treat two NULL values as equivalent.