ORA-00972 标识符太长 - 声明语句
ORA-00972 Identifier too long - Declare statement
我收到 Oracle 错误 ORA-00972 标识符太长。这可能是由于这一行
哪里 EMPLOYEE_ID = &e;
但我就是想不通。
为了测试这一点,我删除了所有 CASE 语句和 serverout 语句,但在 运行 时间输入员工 ID 后我仍然收到错误。
附上 运行 时错误的图片。 Error
set echo on
spool c:\cs422a\wa4spool.txt
SET SERVEROUT ON
DECLARE Emp_rec HR.EMPLOYEES%ROWTYPE;
BEGIN
SELECT *
INTO Emp_rec
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID = &e;
DBMS_OUTPUT.PUT_LINE("---------------------------------------');
CASE Emp_rec.Department_ID
WHEN 10 THEN DBMS_OUTPUT.PUT_LINE('Department: Administration');
WHEN 20 THEN DBMS_OUTPUT.PUT_LINE('Department: Marketing');
WHEN 30 THEN DBMS_OUTPUT.PUT_LINE('Department: Purchasing');
WHEN 40 THEN DBMS_OUTPUT.PUT_LINE('Department: Human Resources');
WHEN 50 THEN DBMS_OUTPUT.PUT_LINE('Department: Shipping');
WHEN 60 THEN DBMS_OUTPUT.PUT_LINE('Department: IT');
WHEN 70 THEN DBMS_OUTPUT.PUT_LINE('Department: Public Relations');
WHEN 80 THEN DBMS_OUTPUT.PUT_LINE('Department: Sales');
WHEN 90 THEN DBMS_OUTPUT.PUT_LINE('Department: Executive');
WHEN 100 THEN DBMS_OUTPUT.PUT_LINE('Department: Finance');
WHEN 110 THEN DBMS_OUTPUT.PUT_LINE('Department: Accounting');
WHEN 120 THEN DBMS_OUTPUT.PUT_LINE('Department: Treasury');
WHEN 130 THEN DBMS_OUTPUT.PUT_LINE('Department: Corporate Tax');
WHEN 140 THEN DBMS_OUTPUT.PUT_LINE('Department: Control and Credit');
WHEN 150 THEN DBMS_OUTPUT.PUT_LINE('Department: Shareholder Services');
WHEN 160 THEN DBMS_OUTPUT.PUT_LINE('Department: Benefits');
WHEN 170 THEN DBMS_OUTPUT.PUT_LINE('Department: Manufacturing');
WHEN 180 THEN DBMS_OUTPUT.PUT_LINE('Department: Construction');
WHEN 190 THEN DBMS_OUTPUT.PUT_LINE('Department: Contracting');
WHEN 200 THEN DBMS_OUTPUT.PUT_LINE('Department: Operations');
WHEN 210 THEN DBMS_OUTPUT.PUT_LINE('Department: IT Support');
WHEN 220 THEN DBMS_OUTPUT.PUT_LINE('Department: NOC');
WHEN 230 THEN DBMS_OUTPUT.PUT_LINE('Department: IT Helpdesk');
WHEN 240 THEN DBMS_OUTPUT.PUT_LINE('Department: Government Sales');
WHEN 250 THEN DBMS_OUTPUT.PUT_LINE('Department: Retail Sales');
WHEN 260 THEN DBMS_OUTPUT.PUT_LINE('Department: Recruiting');
WHEN 270 THEN DBMS_OUTPUT.PUT_LINE('Department: Payroll');
END CASE;
DBMS_OUTPUT.PUT_LINE('Department: ' || Emp_rec.DEPARTMENT_ID);
DBMS_OUTPUT.PUT_LINE('Employee ID: ' || Emp_rec.EMPLOYEE_ID);
DBMS_OUTPUT.PUT_LINE('Employee First Name: ' || Emp_rec.FIRST_NAME);
DBMS_OUTPUT.PUT_LINE('Employee Last Name: ' || Emp_rec.LAST_NAME);
DBMS_OUTPUT.PUT_LINE('Salary: ' || Emp_rec.SALARY);
DBMS_OUTPUT.PUT_LINE('---------------------------------------');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No data found.');
END;
/
第 9 行有错别字:
DBMS_OUTPUT.PUT_LINE("---------------------------------------');
有个双引号,应该是单引号的时候。
在标识符中使用双引号以强制区分大小写(有关详细信息,请参阅 this question)。
在您的示例中,PL/SQL 解析器认为您正在尝试使用名为 ------------------------ --------------(...) 这会导致 ORA-00972.
我收到 Oracle 错误 ORA-00972 标识符太长。这可能是由于这一行
哪里 EMPLOYEE_ID = &e;
但我就是想不通。
为了测试这一点,我删除了所有 CASE 语句和 serverout 语句,但在 运行 时间输入员工 ID 后我仍然收到错误。
附上 运行 时错误的图片。 Error
set echo on
spool c:\cs422a\wa4spool.txt
SET SERVEROUT ON
DECLARE Emp_rec HR.EMPLOYEES%ROWTYPE;
BEGIN
SELECT *
INTO Emp_rec
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID = &e;
DBMS_OUTPUT.PUT_LINE("---------------------------------------');
CASE Emp_rec.Department_ID
WHEN 10 THEN DBMS_OUTPUT.PUT_LINE('Department: Administration');
WHEN 20 THEN DBMS_OUTPUT.PUT_LINE('Department: Marketing');
WHEN 30 THEN DBMS_OUTPUT.PUT_LINE('Department: Purchasing');
WHEN 40 THEN DBMS_OUTPUT.PUT_LINE('Department: Human Resources');
WHEN 50 THEN DBMS_OUTPUT.PUT_LINE('Department: Shipping');
WHEN 60 THEN DBMS_OUTPUT.PUT_LINE('Department: IT');
WHEN 70 THEN DBMS_OUTPUT.PUT_LINE('Department: Public Relations');
WHEN 80 THEN DBMS_OUTPUT.PUT_LINE('Department: Sales');
WHEN 90 THEN DBMS_OUTPUT.PUT_LINE('Department: Executive');
WHEN 100 THEN DBMS_OUTPUT.PUT_LINE('Department: Finance');
WHEN 110 THEN DBMS_OUTPUT.PUT_LINE('Department: Accounting');
WHEN 120 THEN DBMS_OUTPUT.PUT_LINE('Department: Treasury');
WHEN 130 THEN DBMS_OUTPUT.PUT_LINE('Department: Corporate Tax');
WHEN 140 THEN DBMS_OUTPUT.PUT_LINE('Department: Control and Credit');
WHEN 150 THEN DBMS_OUTPUT.PUT_LINE('Department: Shareholder Services');
WHEN 160 THEN DBMS_OUTPUT.PUT_LINE('Department: Benefits');
WHEN 170 THEN DBMS_OUTPUT.PUT_LINE('Department: Manufacturing');
WHEN 180 THEN DBMS_OUTPUT.PUT_LINE('Department: Construction');
WHEN 190 THEN DBMS_OUTPUT.PUT_LINE('Department: Contracting');
WHEN 200 THEN DBMS_OUTPUT.PUT_LINE('Department: Operations');
WHEN 210 THEN DBMS_OUTPUT.PUT_LINE('Department: IT Support');
WHEN 220 THEN DBMS_OUTPUT.PUT_LINE('Department: NOC');
WHEN 230 THEN DBMS_OUTPUT.PUT_LINE('Department: IT Helpdesk');
WHEN 240 THEN DBMS_OUTPUT.PUT_LINE('Department: Government Sales');
WHEN 250 THEN DBMS_OUTPUT.PUT_LINE('Department: Retail Sales');
WHEN 260 THEN DBMS_OUTPUT.PUT_LINE('Department: Recruiting');
WHEN 270 THEN DBMS_OUTPUT.PUT_LINE('Department: Payroll');
END CASE;
DBMS_OUTPUT.PUT_LINE('Department: ' || Emp_rec.DEPARTMENT_ID);
DBMS_OUTPUT.PUT_LINE('Employee ID: ' || Emp_rec.EMPLOYEE_ID);
DBMS_OUTPUT.PUT_LINE('Employee First Name: ' || Emp_rec.FIRST_NAME);
DBMS_OUTPUT.PUT_LINE('Employee Last Name: ' || Emp_rec.LAST_NAME);
DBMS_OUTPUT.PUT_LINE('Salary: ' || Emp_rec.SALARY);
DBMS_OUTPUT.PUT_LINE('---------------------------------------');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No data found.');
END;
/
第 9 行有错别字:
DBMS_OUTPUT.PUT_LINE("---------------------------------------');
有个双引号,应该是单引号的时候。
在标识符中使用双引号以强制区分大小写(有关详细信息,请参阅 this question)。
在您的示例中,PL/SQL 解析器认为您正在尝试使用名为 ------------------------ --------------(...) 这会导致 ORA-00972.