How To Use "IF" Statements on Multiple Conditions?
Submitted by: AdministratorIf you have multiple blocks of codes to be executed based on different conditions, you can use the "IF ... ELSIF" statement. Here is a sample script on IF statements:
DECLARE
day VARCHAR2;
BEGIN
day := 'SUNDAY';
IF day = 'THURSDAY' THEN
DBMS_OUTPUT.PUT_LINE('Checking log files.');
ELSIF day = 'TUESDAY' THEN
DBMS_OUTPUT.PUT_LINE('Helping developers.');
ELSIF day = 'FRIDAY' THEN
DBMS_OUTPUT.PUT_LINE('Rebuild indexes.');
ELSE
DBMS_OUTPUT.PUT_LINE('Reading some papers.');
END IF;
END;
This script should print this:
Reading some papers.
Submitted by: Administrator
DECLARE
day VARCHAR2;
BEGIN
day := 'SUNDAY';
IF day = 'THURSDAY' THEN
DBMS_OUTPUT.PUT_LINE('Checking log files.');
ELSIF day = 'TUESDAY' THEN
DBMS_OUTPUT.PUT_LINE('Helping developers.');
ELSIF day = 'FRIDAY' THEN
DBMS_OUTPUT.PUT_LINE('Rebuild indexes.');
ELSE
DBMS_OUTPUT.PUT_LINE('Reading some papers.');
END IF;
END;
This script should print this:
Reading some papers.
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To View the Dropped Tables in Your Recycle Bin? |
☺ | How To Write Date and Time Interval Literals in Oracle? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | How Run SQL*Plus Commands That Are Stored in a Local File? |
☺ | How To Use "OUT" Parameter Properly? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |