PL/SQL 标识符“字符串”必须声明
谁能告诉我为什么这不会执行?
set serveroutput on ;
Declare
TYPE type_emp IS RECORD(
emp_name employees.last_name%TYPE,
emp_salary employees.salary%TYPE);
rec_emp type_emp;
due_for_a_raise CHAR(1);
begin
SELECT last_name, salary into rec_emp
from employees
where employee_id = 150;
if emp_salary > 5000 then
due_for_a_raise := 'Y';
else
due_for_a_raise := 'N';
end if;
dbms_output.putline(last_name);
dbms_output.putline(salary);
dbms_output.putline(due_for_a_raise);
end;
错误如下,
Error report:
ORA-06550: line 11, column 6:
PLS-00201: identifier 'EMP_SALARY' must be declared
ORA-06550: line 11, column 3:
PL/SQL: Statement ignored
ORA-06550: line 16, column 23:
PLS-00201: identifier 'LAST_NAME' must be declared
ORA-06550: line 16, column 3:
PL/SQL: Statement ignored
ORA-06550: line 17, column 23:
PLS-00201: identifier 'SALARY' must be declared
ORA-06550: line 17, column 3:
PL/SQL: Statement ignored
ORA-06550: line 18, column 15:
PLS-00302: component 'PUTLINE' must be declared
ORA-06550: line 18, column 3:
PL/SQL: Statement ignored
我想我不知道为什么没有声明它,因为它们是在 type_emp 中声明的。
Can anyone tell me why this won't execute?
set serveroutput on ;
Declare
TYPE type_emp IS RECORD(
emp_name employees.last_name%TYPE,
emp_salary employees.salary%TYPE);
rec_emp type_emp;
due_for_a_raise CHAR(1);
begin
SELECT last_name, salary into rec_emp
from employees
where employee_id = 150;
if emp_salary > 5000 then
due_for_a_raise := 'Y';
else
due_for_a_raise := 'N';
end if;
dbms_output.putline(last_name);
dbms_output.putline(salary);
dbms_output.putline(due_for_a_raise);
end;
Errors are below
Error report:
ORA-06550: line 11, column 6:
PLS-00201: identifier 'EMP_SALARY' must be declared
ORA-06550: line 11, column 3:
PL/SQL: Statement ignored
ORA-06550: line 16, column 23:
PLS-00201: identifier 'LAST_NAME' must be declared
ORA-06550: line 16, column 3:
PL/SQL: Statement ignored
ORA-06550: line 17, column 23:
PLS-00201: identifier 'SALARY' must be declared
ORA-06550: line 17, column 3:
PL/SQL: Statement ignored
ORA-06550: line 18, column 15:
PLS-00302: component 'PUTLINE' must be declared
ORA-06550: line 18, column 3:
PL/SQL: Statement ignored
I guess I don't know why it isn't being declared since they are being declared in the type_emp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您引用它们时,您需要使用该记录。对
dbms_output.put_line
的调用还需要在put
和line
之间使用下划线。You'd need to use the record when you're referencing them. Your calls to
dbms_output.put_line
also need to have an underscore betweenput
andline
.