This is my code:
DECLARE
v_grade CHAR(1) := UPPER('&grade');
appraisal VARCHAR(20);
BEGIN
appraisal := CASE v_grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
WHEN 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE('Grade: '||v_grade||'Appraisal '||appraisal);
END;
/
this is the full error code:
ERROR at line 10:
ORA-06550: line 10, column 1:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
* & = - + < / > at in is mod remainer not rem then
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 between || multiset member submultiset.
I'm learning PL/SQL and I was trying an example from my book but it seems I did something wrong, please don't just give the answer I want to know how you troubleshooted this and how I did make the mistake.
Your final clause should use ELSE
instead of WHEN
:
DECLARE
v_grade CHAR(1) := 'C';
appraisal VARCHAR(20);
BEGIN
appraisal :=
CASE v_grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE('Grade: '||v_grade||', Appraisal '||appraisal);
END;
UPDATE
Giving you advice on how to troubleshoot this isn't easy (since it's largely a matter of personal preference); things I usually try are
CASE
)