Calling a stored PROCEDURE in Toad

倾然丶 夕夏残阳落幕 提交于 2019-11-27 07:43:22

问题


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.

回答1:


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

or

begin
proc(1);
end;


来源:https://stackoverflow.com/questions/14639604/calling-a-stored-procedure-in-toad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!