Database Reference
In-Depth Information
An ELSIF statement has the following structure:
IF condition1 THEN
Statement1;
ELSIF condition2 THEN
statements 2;
ELSIF condition THEN
Statements 3;
……………
ELSE
last_statement;
END IF;
Example 5:
DECLARE
num NUMBER := &inputnum;
BEGIN
IF num < 0 THEN
DBMS_OUTPUT.PUT_LINE (num||' is a negative number');
ELSIF num = 0 THEN
DBMS_OUTPUT.PUT_LINE (num||' is equal to zero');
ELSE
DBMS_OUTPUT.PUT_LINE (num||' is a positive number'); END IF;
END;
8.7.4 CASE Statements
CASE statement is an understandable and efficient alternative to a long series of
IF tests on the same expression. There are two forms of the CASE statement: simple and
searched . Syntax of the so-called simple CASE statement is:
CASE selector
WHEN expression1 THEN statement1;
WHEN expression2 THEN statements2;
...
WHEN expression m THEN statement m; ELSE statement m+1;
END CASE;
Example 6:
DECLARE
num NUMBER := &input_num; num2 NUMBER;
BEGIN
Num2 := MOD(num,2);
Search WWH ::




Custom Search