Conditional Statements

Within PLSQL conditional statements can be used to determine what action to take based on other actions or data retrieved. The main statements within this are the IF and CASE statements.

Syntax

IF
THEN

ELSE

END IF;
CASE [ expression ]
WHEN THEN
WHEN THEN
ELSE
END

Example

IF v_employee_surname = ‘Smith’
THEN
v_smith_count := v_smith_count + 1;
ELSE
V_other_count := v_other_count + 1;
END IF;
CASE
WHEN v_employee_surname = ‘Smith’
THEN v_smith_count := v_smith_count + 1;
ELSE v_other_count := v_other_count + 1;
END;

Leave a Reply

Your email address will not be published. Required fields are marked *