Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

oracle - Calling a stored PROCEDURE in 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;

And trying to call it:

getempsal(1,'JAN',OUT) --Invalid sql statement.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...