在 Toad 中调用存储的 PROCEDURE

2021-12-20 00:00:00 oracle stored-procedures toad

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

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;

并尝试调用它:

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

推荐答案

你的过程包含一个 out 参数,所以你需要像这样在块中调用它:

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

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);

begin
proc(1);
end;

相关文章