简体   繁体   English

如何从SQL Plus执行存储过程?

[英]How to Execute stored procedure from SQL Plus?

I have a stored procedure in oracle and want to test it from SQLPlus. 我在oracle中有一个存储过程,想要从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 proc的开始就是这个

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? 我是否需要为out参数提供一个var,是这样的? I tried: 我试过了:

var z  NUMBER;

But get this error when I try to run the proc 但是当我尝试运行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: 此外,当我在SQL-Developer中它给了我用法,它以相反的顺序显示输入,即:

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 你是以相反的顺序提供它们还是只是用SQL-Developer提供它们

I did not write the procedure and I don't normally deal with them so I could be missing something obvious. 我没有编写程序,我通常不会处理它们,所以我可能会遗漏一些明显的东西。

Thanks 谢谢

You have two options, a PL/SQL block or SQL*Plus bind variables: 您有两个选项,PL / SQL块或SQL * Plus绑定变量:

var z number

execute  my_stored_proc (-1,2,0.01,:z)

print z

You forgot to put z as an bind variable. 你忘了把z作为绑定变量。

The following EXECUTE command runs a PL/SQL statement that references a stored procedure: 以下EXECUTE命令运行引用存储过程的PL / SQL语句:

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 请注意,存储过程返回的值将返回到:Z

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM