3-2. Choosing Between Two Mutually Exclusive Conditions
Problem
You have two conditions that are mutually exclusive. You want to execute one set of statements if the first condition evaluates to TRUE
. Otherwise, if the first condition is FALSE
or NULL
, then execute a different set of statements.
Solution
Use an IF-ELSE
statement to evaluate the condition and execute the statements that correspond to it if the condition evaluates to TRUE
. In the following example, a given employee ID is used to query the EMPLOYEES
table. If that employee exists, then the employee record will be retrieved. If not found, then a message will be displayed stating that no match was found.
DECLARE
employee employees%ROWTYPE; emp_count ...
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.