1

I am using SQL Developer and writing this PL/SQL code. But I am getting error, when i gave B as option. Please help.

SET SERVEROUTPUT ON

accept q_grade char prompt 'EnterGrade: '
DECLARE
v_grade CHAR(1) := UPPER(&q_grade);
v_appraisal VARCHAR(20);

BEGIN
v_appraisal := CASE v_grade WHEN v_grade = 'A' THEN 'Excellent'
WHEN v_grade = 'B' THEN 'Good'
WHEN v_grade = 'C' THEN 'FAIL'
ELSE 'NO SUCH GRADES'
END;

DBMS_OUTPUT.PUT_LINE ('Grade:  ' || v_grade  || ' Appraisal  ' ||v_appraisal);

END;
/

Error report:

ORA-06550: line 2, column 26:
PLS-00201: identifier 'B' must be declared
ORA-06550: line 2, column 9:
PL/SQL: Item ignored
ORA-06550: line 6, column 21:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored
ORA-06550: line 12, column 57:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 12, column 21:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
1

2 Answers 2

2

Change:

v_grade CHAR(1) := UPPER('&q_grade');

and

v_appraisal := CASE WHEN v_grade = 'A' THEN 'Excellent'
Sign up to request clarification or add additional context in comments.

Comments

1

You need to remove the extra v_grade right after the CASE statement:

BEGIN
v_appraisal := CASE WHEN v_grade = 'A' THEN 'Excellent'
/* -- here --------^ */

1 Comment

@JeffreyKemp - whoooops! You're right - I shouldn't try to look at code at midnight. :-) Earlier comment deleted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.