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 ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.