How does Oracle perform an OR check?

In Java, the logical condition OR behaves such that if the first condition true, then it does not evaluate the second condition.

For example:

int a = 10;
if (a == 10 || a == 0) {
    // Logic
}

Java does not evaluate the second test ( a == 0) as the first condition ( a == 10) true.

If we have an Oracle SQL statement:

select * from student where city = :city and 
    (:age is null or age > :age)

How are graded (age > :age or :age is null)? If the parameter :ageis equal NULL, then it also evaluates the second condition?

+4
source share
3 answers

PL / SQL

In PL / SQL, Oracle OR is another example of short circuit assessment. Oracle PL / SQL Fundamentals Speaks (Partially)

Short circuit rating

PL/SQL . PL/SQL , . , .

SQL

SQL OR . @JonHeller , , , 0.

+2

. , . , , . SQL , .

"", , , .

+7

Oracle . . , null .

:age is null or age > :age

age > nvl(:age, age - 1)
+1

Source: https://habr.com/ru/post/1619785/


All Articles