8

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.
Drew
  • 29,895
  • 7
  • 74
  • 104
user1050619
  • 19,822
  • 85
  • 237
  • 413
  • Toad is a **GUI based client tool**, unlike SQL*Plus. So, you could directly view the Procedure and execute it from the tool itself. – Lalit Kumar B Nov 25 '15 at 11:27

2 Answers2

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;
Florin Ghita
  • 17,525
  • 6
  • 57
  • 76
  • 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. – sasha_gud Apr 02 '16 at 19:15
  • 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. – sasha_gud Sep 18 '16 at 19:00
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.