我正在使用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'的周圍。 –