[sql] 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

This question is related to sql oracle stored-procedures

The answer is


You forgot to put z as an bind variable.

The following EXECUTE command runs 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 being return into :Z


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

Examples related to sql

Passing multiple values for same variable in stored procedure SQL permissions for roles Generic XSLT Search and Replace template Access And/Or exclusions Pyspark: Filter dataframe based on multiple conditions Subtracting 1 day from a timestamp date PYODBC--Data source name not found and no default driver specified select rows in sql with latest date for each ID repeated multiple times ALTER TABLE DROP COLUMN failed because one or more objects access this column Create Local SQL Server database

Examples related to oracle

concat yesterdays date with a specific time ORA-28001: The password has expired how to modify the size of a column How to create a blank/empty column with SELECT query in oracle? Find the number of employees in each department - SQL Oracle Query to display all tablespaces in a database and datafiles When or Why to use a "SET DEFINE OFF" in Oracle Database How to insert date values into table error: ORA-65096: invalid common user or role name in oracle In Oracle SQL: How do you insert the current date + time into a table?

Examples related to stored-procedures

How to create temp table using Create statement in SQL Server? How do I pass a list as a parameter in a stored procedure? SQL Server IF EXISTS THEN 1 ELSE 2 Stored procedure with default parameters Could not find server 'server name' in sys.servers. SQL Server 2014 How to kill all active and inactive oracle sessions for user EXEC sp_executesql with multiple parameters MySQL stored procedure return value SQL Server: use CASE with LIKE SQL server stored procedure return a table