IF condition
THEN
Statement;
END IF;
IF condition
THEN
[Statements to execute when condition is TRUE]
ELSE
[Statements to execute when condition is FALSE]
END IF;
IF Condition1
THEN
Statements to execute when condition1 is TRUE
ELSIF condition2
THEN
Statements to execute when condition2 is TRUE
END IF;
IF condition1
THEN
Statements to execute when condition1 is TRUE
ELSIF condition2
THEN
Statements to execute when condition2 is TRUE
ELSE
Statements to execute when both condition1 and condition2 are FALSE
END IF;
DECLARE
a number(3) := 200;
BEGIN
-- check the boolean condition using if statement
IF( a < 10 ) THEN
-- if condition is true then print the following
dbms_output.put_line('a is less than 10 ' );
ELSE
dbms_output.put_line('a is not less than 10 ' );
END IF;
dbms_output.put_line('value of a is : ' || a);
END;
CASE [expression]
WHEN condition1 THEN result1
WHEN condition2 THEN result2
…....................
WHEN condition_n THEN result_n
ELSE result
END;
DECLARE
grade char(1) := 'C';
BEGIN
CASE grade
when 'A' then dbms_output.put_line('Distinction');
when 'B' then dbms_output.put_line('First class');
when 'C' then dbms_output.put_line('Second class');
when 'D' then dbms_output.put_line('Pass class');
else dbms_output.put_line('Failed');
END CASE;
END;
/
LOOP
Sequence of statements;
END LOOP;
LOOP
Statements;
EXIT;
[or EXIT WHEN condition;]
END LOOP;
DECLARE
i NUMBER := 1;
BEGIN
LOOP
EXIT WHEN i>5;
dbms_output.put_line(i);
i := i+1;
END LOOP;
END;
WHILE [condition]
LOOP Statements;
END LOOP;
DECLARE
i INTEGER := 1;
BEGIN
WHILE i <= 5 LOOP
dbms_output.put_line(i);
i := i+1;
END LOOP;
END;
FOR counter IN initial_value .. final_value LOOP
LOOP statements;
END LOOP;
BEGIN
FOR k IN 1..5 LOOP
dbms_output.put_line(k)
END LOOP;
END;
I) GOTO label_name;
II) GOTO label_name;
…....
…....
<<label_name>>
Statement;
DECLARE
a number(2) := 50;
BEGIN
<<loopstart>>
-- while loop execution
WHILE a < 60LOOP
dbms_output.put_line ('value of a: ' || a);
a := a + 1;
IF a = 55 THEN
a := a + 1;
GOTO loopstart;
END IF;
END LOOP;
END;
/