Calling a stored PROCEDURE in Toad
Asked Answered
J

2

9

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.
Jiffy answered 1/2, 2013 at 4:12 Comment(1)
Toad is a GUI based client tool, unlike SQL*Plus. So, you could directly view the Procedure and execute it from the tool itself.Ostend
T
16

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;
Tarragona answered 1/2, 2013 at 4:21 Comment(2)
If procedure returns cursor, just declare it and then do the following: :output := cursor; This will print the cursor content in the data grid.Tallith
One more useful thing - you can all stored procedure with output cursor like this: exec package_name.procedure_name('param', 'param2', :0) and you'll get cursor content in the datagrid.Tallith
P
0

Just write EXECUTE procedure_name('provide_the_valueof_IN parameter','value of in parameter', :k) ;

Run this statement a popup will come set the parameters as in out and the datatype too. U will see the output in another popup window.

Polygnotus answered 4/3, 2021 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.