Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 972
user1050619 Avatar asked Feb 01 '13 04:02

user1050619


People also ask

How do I run a db2 stored procedure in Toad?

Use your panel control on your left find the procedure, right click on it, pick the execute function from the pull down and left click on it. A new window will open plug your value for your parameters and execute. Simple.

How do you call a stored procedure?

You can call an SQL stored procedure with the execute, open, or get statement; in each case, you use the #sql directive. A stored procedure is a set of instructions for a database, like a function in EGL.

How do I open a stored procedure in Toad?

In Toad, click on menu Database > Schema Browser. Select the Procedure from drop-down menu or from the Tab (if Schema Browser configured as Tab). Then list of procedures will be displayed for the current user. Then select a stored procedure and do the right click on it.


1 Answers

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;
like image 59
Florin stands with Ukraine Avatar answered Sep 28 '22 07:09

Florin stands with Ukraine