Short-circuit evaluation-pl/sql expressions , PL-SQL Programming

Short-Circuit Evaluation

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

on_hand INTEGER;
on_order INTEGER;
IF (on_hand = 0) OR ((on_order / on_hand) < 5) THEN

Whenever the value of on_hand is zero, the left operand yields TRUE, so the PL/SQL require not compute the right operand. If PL/SQL were to compute both operands before applying the OR operator, the right operand would cause a division by the zero error. In any case, it is a poor programming practice to rely on the short-circuit computation.

Posted Date: 10/3/2012 5:19:05 AM | Location : United States

Related Discussions:- Short-circuit evaluation-pl/sql expressions , Assignment Help, Ask Question on Short-circuit evaluation-pl/sql expressions , Get Answer, Expert's Help, Short-circuit evaluation-pl/sql expressions Discussions

Write discussion on Short-circuit evaluation-pl/sql expressions
Your posts are moderated
Related Questions
Example of UNWRAP Operator - SQL Example here shows how unwrapping can be done in longhand in SQL. Example: Unwrapping in SQL Letting CONTACT_INFO_WRAPPED denote the res

EXECUTE Privilege To call an invoker-rights routine straightforwardly, the users should have the EXECUTE privilege on that routine. By yielding the privilege, you permit a user

Advantages of Wrapping   The PL/SQL Wrapper convert the PL/SQL source code into a transitional form of the object code. By hiding the application internals, the Wrapper secure

Count Operator in SQL Example: Counting the students who have scored more than 50 in some exam (SELECT COUNT (*) FROM (SELECT DISTINCT StudentId FROM EXAM_MARK WHE

Fetching Across Commits The FOR UPDATE clauses acquire exclusive all row locks. All rows are locked when you open the cursor, and when you commit your transaction they are unl

Write a query to find academics that are authors and that have only ever coauthored papers with authors from institutes in the same state as their own. List their academic number,

Subprograms The PL/SQL has two types of subprograms known as the procedures and functions that can take parameters and be invoked. As the following example represents, a subp

Hi there, I have the final part of a submission to do, it is a demonstration that takes place tomorrow. I do not have to use previous information, but i have resources that sho

If two relations R and S are joined, then the non matching tuples of both R and S are ignored in __________________.

What is Cursors how to use it in Real time application ?