我正在使用SQL Developer并编写此PL/SQL代码。但是当我给出B选项时,我正在出错。请帮忙。在PL/SQL代码中使用替换变量
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;
/
错误报告:
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:
将单引号放在'&q_grade'的周围。 –