oracle PL/SQL 过程语句忽略错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8871116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:51:17  来源:igfitidea点击:

PL/SQL procedure statement ignored error

oracleplsql

提问by aretai

I'm doing tutorial from website http://www.plsqltutorial.com/plsql-procedure/. I have run the code on apex:

我正在从网站http://www.plsqltutorial.com/plsql-procedure/做教程。我已经在 apex 上运行了代码:

CREATE OR REPLACE PROCEDURE adjust_salary(
    in_employee IN EMPLOYEES.EMPLOYEE_ID%TYPE,
    in_percent IN NUMBER
) IS
BEGIN
    UPDATE EMPLOYEES
    SET salary = salary + salary * in_percent / 100
    WHERE employee_id = in_employee_id;
END;

but I got error:

但我有错误:

Error at line 6: PL/SQL: SQL Statement ignored

4. ) IS
5. BEGIN
6.  UPDATE EMPLOYEES
7.  SET salary = salary + salary * in_percent / 100
8.  WHERE employee_id = in_employee_id;

I have checked and table employees is there. What is the problem and how to fix it?

我已经检查过,表员工在那里。有什么问题以及如何解决?

采纳答案by Sathyajith Bhat

WHERE employee_id = in_employee_id;

WHERE employee_id = in_employee_id;

in_employee_idis not declared, neither is it a parameter. The function definition says the parameter is in_employeeso your code block should be

in_employee_id没有声明,也不是参数。函数定义说参数是in_employee这样你的代码块应该是

CREATE OR REPLACE PROCEDURE adjust_salary(
    in_employee IN EMPLOYEES.EMPLOYEE_ID%TYPE,
    in_percent IN NUMBER
) IS
BEGIN
    UPDATE EMPLOYEES
    SET salary = salary + salary * in_percent / 100
    WHERE employee_id = in_employee;
END;


Looking at the article, I see that you've made a typo while creating the function, the function declaration as per the article is

查看文章,我看到您在创建函数时犯了一个错字,文章中的函数声明是

 CREATE OR REPLACE PROCEDURE adjust_salary(
    in_employee_id IN EMPLOYEES.EMPLOYEE_ID%TYPE,

So, if you change your code to the above, no changes are required to the update statement.

因此,如果您将代码更改为上述内容,则无需更改更新语句。

回答by John Doyle

The parameter is in_employeebut you're using in_employee_idin your update. Change to:

该参数是in_employee但您in_employee_id在更新中使用。改成:

CREATE OR REPLACE PROCEDURE adjust_salary(
    in_employee IN EMPLOYEES.EMPLOYEE_ID%TYPE,
    in_percent IN NUMBER
) IS
BEGIN
    UPDATE EMPLOYEES
    SET salary = salary + salary * in_percent / 100
    WHERE employee_id = in_employee;
END;