oracle 在 Toad 中调用存储的 PROCEDURE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14639604/
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 04:49:27  来源:igfitidea点击:

Calling a stored PROCEDURE in Toad

oraclestored-procedurestoad

提问by user1050619

I have a defined a new stored procedure but get a error while calling it,

我定义了一个新的存储过程,但在调用它时出错,

CREATE OR REPLACE PROCEDURE SCOTT.getempsal(
        p_emp_id IN NUMBER,
        p_emp_month IN CHAR,
        p_emp_sal OUT INTEGER)

AS
BEGIN
    SELECT EMP_SAL
      INTO p_emp_sal
      FROM EMPLOYEE_SAL
    WHERE  EMP_ID = p_emp_id
    AND    EMP_MONTH = p_emp_month;

END getempsal;

And trying to call it:

并尝试调用它:

getempsal(1,'JAN',OUT) --Invalid sql statement.

回答by Florin Ghita

Your procedure contains an out parameter, so you need to call it in block like:

您的过程包含一个 out 参数,因此您需要在块中调用它,例如:

declare
a number;
begin 
  getempsal(1,'JAN',a);
  dbms_output.put_line(a);
end;

A simple procedure (let's say with a number parameter) can be called with

一个简单的过程(假设有一个数字参数)可以用

exec proc(1);

or

或者

begin
proc(1);
end;