tags:

views:

96

answers:

2

I know in C like languages logical operators are evaluated one at a time so:

false && really_expensive_function()

is doesn't result in the function being called (I can't remember the CS name for this). Does the same happen in PL/SQL or do I need to break the IF parts out to separate blocks?

+5  A: 

The CS name is short-circuiting (wikipedia entry on short-circuit evaluation) and yes, plsql does exactly that.

ChristopheD
+1 It should not only do that, it **does** it :)
Peter Lang
Ace cheers - you never know with some of the crazy things in the world of PL/SQL
Chris
@Chris: That's true :) Have a look at this one for example: http://stackoverflow.com/questions/2021140/why-does-nvl-always-evaluate-2nd-parameter
Peter Lang
+1 Maybe you should update your answer to say "does" rather than "should" to dispel any doubt!
Tony Andrews
@Chris, @Tony Andrews: thanks, I've updated the answer to avoid possible confusion.
ChristopheD
A: 

I think the term you are looking for is "lazy evaluation". You may want to look at this question.

klausbyskov