Does anyone know, why Oracle\'s NVL
(and NVL2
) function always evaluate the second parameter, even if the first parameter is not NULL
?
Here is a post where Tom Kyte confirms that decode
and case
short circuit but not nvl
but he doesn't give justification or documentation for why. Just states it to be:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:926029357278#14932880517348
So in your case you should use decode
or case
instead of nvl
if an expensive function will be called in your query.