IF and CASE
Oracle Fusion / EBS · Technical · PL/SQL
GeneralHigh confidence
IF/ELSIF/ELSE branches on conditions; CASE comes in simple and searched forms.
Grounded in: Curated Oracle knowledge layer — PL/SQL
How it works
IF...ELSIF...ELSE branches on one or more boolean conditions, evaluated top to bottom until one is true. CASE comes in two forms: a simple CASE compares one expression against several possible values, while a searched CASE evaluates independent boolean conditions — both can be used as a statement (CASE...END CASE) or, more commonly, as an expression that returns a value.
How it works
DECLARE
v_salary NUMBER := 5500;
v_grade VARCHAR2(10);
BEGIN
v_grade := CASE
WHEN v_salary >= 10000 THEN 'A'
WHEN v_salary >= 5000 THEN 'B'
ELSE 'C'
END;
IF v_grade = 'A' THEN
DBMS_OUTPUT.PUT_LINE('Top grade');
ELSIF v_grade = 'B' THEN
DBMS_OUTPUT.PUT_LINE('Mid grade');
ELSE
DBMS_OUTPUT.PUT_LINE('Entry grade');
END IF;
END;
/Related Questions
Have a follow-up, or a different question?
Continue in Ask Oracle AI