PLS-00201 必须声明标识符

PLS-00201 Identifier must be declared

这一定很容易修复,但由于某种原因我无法让它工作。我一直收到错误

PLS-00201: identifier 'ART' must be declared

我的代码如下:

create or replace PROCEDURE question1(givenType IN VARCHAR, output OUT CHAR,output1 OUT CHAR)
AS
BEGIN
SELECT TITLE into output FROM CLASS where TYPE=givenType;
SELECT INSTRUCTOR into output1 FROM CLASS where TYPE=givenType;
DBMS_OUTPUT.PUT_LINE('The title of any classes with that type is: '|| output|| 'The instructor that taught each class is: ' || output1);
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No data found');
END;

我认为问题可能是当用户输入 "Art" 时,程序将其作为 "ART" 接受,因为我的 table 类型是 "Art" 而不是 "ART" 那么这就是我得到错误的原因。我似乎不知道如何修复它才能正常工作。有帮助吗?

对不起各位,我昨晚睡着了这里是我得到的完整错误

Connecting to the database CS425 Spring 2015.
ORA-06550: line 6, column 16:
PLS-00201: identifier 'ART' must be declared
ORA-06550: line 6, column 3:
PL/SQL: Statement ignored
Process exited.
Disconnecting from the database CS425 Spring 2015.

PLS-00201: identifier 'ART' must be declared

I think the problem may be that when the user inputs "Art" the program takes it in as "ART" and since my table type is "Art" not "ART" then that's why I get the error.

与UPPER/LOWER案无关。查询被解析为:

SELECT TITLE into output FROM CLASS where TYPE=ART;

如果类型是 varchar 类型,那么您必须将值作为字符串传递,即您必须将其括在单引号内。否则,Oracle 会将其解释为 标识符 。所以,应该是:

SELECT TITLE into output FROM CLASS where TYPE='ART';

例如,

SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2    o_dept NUMBER;
  3  BEGIN
  4    SELECT DEPTNO INTO o_dept FROM EMP WHERE ENAME=SCOTT;
  5    dbms_output.put_line(o_dept);
  6  END;
  7  /
  SELECT DEPTNO INTO o_dept FROM EMP WHERE ENAME=SCOTT;
                                                 *
ERROR at line 4:
ORA-06550: line 4, column 50:
PL/SQL: ORA-00904: "SCOTT": invalid identifier
ORA-06550: line 4, column 3:
PL/SQL: SQL Statement ignored


SQL> DECLARE
  2    o_dept NUMBER;
  3  BEGIN
  4    SELECT DEPTNO INTO o_dept FROM EMP WHERE ENAME='SCOTT';
  5    dbms_output.put_line(o_dept);
  6  END;
  7  /
20

PL/SQL procedure successfully completed.

SQL>

并且,使用保留关键字作为对象名称并不是一个好主意。 TYPE 是保留关键字。