Quick Search:
 
 The Oracle ELSE Keyword      [Return To Index] Jump to:  

Term: ELSE

Definition:
The Oracle ELSE keyword is an optional part of the IF...THEN...ELSE conditional construct in PL/SQL, which is used to provide set of alternate statements or execution paths. When the condition specified against IF fails, the program flow proceeds to the ELSE part and the specified statements are executed. After the execution is over, Oracle skips the IF...THEN...ELSE constructs and moves the next statement in the sequence for execution.

For example, the following code checks the age of a person and decides if they are a Senior Citizen or not. If they are older than 60 they are considered to be a Senior Citizen. If the age is less than 60 then the ELSE clause is executed and the string 'Not a Senior Citizen' is printed.

DECLARE
L_AGE NUMBER := 40;
BEGIN
IF L_AGE > 60 THEN
DBMS_OUTPUT.PUT_LINE('Senior Citizen');
ELSE
DBMS_OUTPUT.PUT_LINE('Not a Senior Citizen');
END IF;
DBMS_OUTPUT.PUT_LINE('Execution Over');
END;

Not a Senior Citizen
Execution Over

PL/SQL procedure successfully completed.


Related Links:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org