IF and CASE
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
IF/ELSIF/ELSE branches on conditions; CASE comes in simple and searched forms.
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
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.