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