Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle ELSE Keyword      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

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      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 251 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?