Home » SQL & PL/SQL » SQL & PL/SQL » what is short circuit evaluation
what is short circuit evaluation [message #238278] Thu, 17 May 2007 05:15 Go to next message
sv.venkat
Messages: 12
Registered: July 2006
Location: HYDERABAD
Junior Member
Dear friends,
I came across the term 'SHORT CIRCUIT EVALUATION' in Oracle.Any idea about this is heartly welcome.
Thanks in advance.
Venkat.
Re: what is short circuit evaluation [message #238281 is a reply to message #238278] Thu, 17 May 2007 05:23 Go to previous messageGo to next message
shanthkumaar
Messages: 156
Registered: February 2007
Location: india,chennai
Senior Member

hi,

Short-Circuit Evaluation

When evaluating a logical expression, PL/SQL uses short-circuit evaluation. 
That is, PL/SQL stops evaluating the expression as soon as the result can be determined.
 This lets you write expressions that might otherwise cause an error. 
Consider the following OR expression:

DECLARE
   on_hand  INTEGER := 0;
   on_order INTEGER := 100;
BEGIN
-- Does not cause divide-by-zero error; evaluation stops after 1st expr.
   IF (on_hand = 0) OR ((on_order / on_hand) < 5) THEN
      dbms_output.put_line('There are no more widgets left!');
   END IF;
END;
/

When the value of on_hand is zero, 
the left operand yields TRUE, so
 PL/SQL does not evaluate the right operand. 
If PL/SQL evaluated both operands before applying the 
OR operator, the right operand would cause a 
division by zero error


i got the above from here
regards
shanth

[Updated on: Thu, 17 May 2007 05:25]

Report message to a moderator

Re: what is short circuit evaluation [message #238538 is a reply to message #238281] Fri, 18 May 2007 08:25 Go to previous message
sv.venkat
Messages: 12
Registered: July 2006
Location: HYDERABAD
Junior Member
Dear Shanthkumar,
I got answer from your reply. Thank You.
Regards
Venkat.
Previous Topic: call vs exec in oracle
Next Topic: query process help
Goto Forum:
  


Current Time: Mon Dec 05 04:26:45 CST 2016

Total time taken to generate the page: 0.14711 seconds