【问题标题】:PL/SQL: SQL Statement Ignored & ORA - 00984: Column Not Allowed HerePL/SQL:忽略 SQL 语句和 ORA - 00984:此处不允许列
【发布时间】:2016-12-15 04:52:07
【问题描述】:

我的存储过程存在一些问题。如果你能帮助我,那就太好了。谢谢!

Create or replace procedure final(Minimum in number)

is

Cursor salary_cursor(Minimum_salary number) is
  select first_name || ' ' || last_name employee, department_name, job_title,
  min_salary, salary from employees
  join departments using (department_id)
  join jobs using (job_id)
  where Minimum_salary <= min_salary;

begin
  for x in salary_cursor(Minimum) loop
    insert into finalrept values(n.Employee_name, n.department_name, n.job_title,
    n.min_salary, n.salary);

end loop;

Exception
  when others then
    dbms_output.put_line(SQLERRM || ', ' || SQLCODE);

end final;
/
sho err

我似乎无法弄清楚为什么会出现这些错误!任何帮助表示赞赏。

【问题讨论】:

  • 删除WHEN OTHERS异常块,它隐藏了实际的错误和行号。作为一种良好的编码实践,它本身被认为是一个错误。见WHEN OTHERS – A bug
  • n. s 替换为 x.
  • 为什么采用这种缓慢的逐行游标方法?整个过程可以用单个insert 语句替换。无需 PL/SQL

标签: sql oracle stored-procedures plsql


【解决方案1】:

我可以通过查看代码来建议一些事情,当您 insert 时,您需要插入 x.column_name 不确定为什么要使用 n.column_name ,还要确保 column_name 与您的选择查询匹配。我在插入时看到了employee_name,但在查询中看到了它的员工

【讨论】:

  • 就是这样!我没有看到employee_name 和查询之间的区别。谢谢!
猜你喜欢
  • 1970-01-01
  • 2020-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多