How to execute a stored procedure from SQL Plus?

I have a stored procedure in oracle and you want to test it from SQLPlus.

If i use

execute my_stored_proc (-1,2,0.01) 

I get this error

 PLS-00306: wrong number or types of arguments in call to my_stored_proc 

The beginning for proc is

 create or replace PROCEDURE my_stored_proc ( a IN NUMBER, b IN NUMBER, c IN NUMBER, z out NUMBER ) AS .... 

Do I need to provide a var parameter for the out parameter, right? I tried:

 var z NUMBER; 

But I get this error when I try to run proc

 execute my_stored_proc (-1,2,0.01,z) PLS-00201: identifier 'Z' must be declared 

Also, when I was in SQL-Developer, it gave me the ability to use, and it shows the inputs in the reverse order, i.e.:

 execute my_stored_proc(z number,c number,b number,a number); 

Do you provide them in reverse or is it just something with SQL-Developer

I did not write the procedure, and I usually do not understand them, so I could have missed something obvious.

thanks

+7
sql oracle stored-procedures
source share
2 answers

You have two options: a PL / SQL block or SQL * Plus bind variables:

 var z number execute my_stored_proc (-1,2,0.01,:z) print z 
+14
source share

You forgot to put z as a binding variable.

The following EXECUTE command launches a PL / SQL statement that references a stored procedure:

 SQL> EXECUTE - > :Z := EMP_SALE.HIRE('JACK','MANAGER','JONES',2990,'SALES') 

Note that the value returned by the stored procedure is returned in: Z

-one
source share

All Articles