PLS-00615: type mismatch found at between CASE operand and WHEN operands

PLS-00615: type mismatch found at between CASE operand and WHEN operands

Oracle PL/SQL error message: PLS-00615: type mismatch found at ‘string’ between CASE operand and WHEN operands

Cause:

In a simple CASE statement or expression, the CASE operand and WHEN operands do not match in datatype, and it is unclear which implicit conversion is required to correct the mismatch.

Solution:

Change the CASE operand and WHEN operands so that their datatypes match.

Example:

DECLARE
    v_num NUMBER:=2;
    v_out VARCHAR2(12);
BEGIN
    CASE v_num
        WHEN v_num=1 THEN v_out:='A'; 
        WHEN v_num=2 THEN v_out:='B';
        ELSE v_out:='C';
    END CASE;
    DBMS_OUTPUT.put_line(v_out);
END;

Output:

PLS-00615: type mismatch found at ‘V_NUM’ between CASE operand and WHEN operands

Correct

DECLARE
    v_num NUMBER:=2;
    v_out VARCHAR2(12);
BEGIN
    CASE v_num
        WHEN 1 THEN v_out:='A'; 
        WHEN 2 THEN v_out:='B';
        ELSE v_out:='C';
    END CASE;
    DBMS_OUTPUT.put_line(v_out);
END;

Output:

B