Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Execute stored procedure from SQL Plus?

I have a stored procedure in oracle and 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 the proc is this

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 the a var for the out parameter, is so how? I tried:

var z  NUMBER;

But get this error when I try to run the 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 usage and it show the inputs in reverse order, that is:

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

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

I did not write the procedure and I don't normally deal with them so I could be missing something obvious.

Thanks

like image 341
cody Avatar asked Jan 22 '10 06:01

cody


1 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
like image 148
Thilo Avatar answered Oct 31 '22 13:10

Thilo