O'Reilly logo

Oracle and PL/SQL Recipes: A Problem-Solution Approach by Matt Arena, Josh Juneau

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3-3. Evaluating Multiple Mutually Exclusive Conditions

Problem

Your application has multiple conditions to evaluate, and each of them is mutually exclusive. If one of the conditions evaluates to FALSE, you'd like to evaluate the next one. You want that process to continue until there are no more conditions.

Two solutions are possible: one using IF and the other using CASE.

Solution #1

Use an IF-ELSIF-ELSE statement to perform an evaluation of all mutually exclusive conditions. The following example is a SQL*Plus script that queries how many countries are in a specified region.

Image Note The following example uses SQL*Plus substitution variables. Be ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required