Rup*_*esh 3 sql vb.net oracle oracle11g
如何从sqlplus调用存储过程?
我有一个程序:
Create or replace procedure testproc(parameter1 in varachar2,parameter2 out varchar2)
begin
Do something
end;
Run Code Online (Sandbox Code Playgroud)
我试过exec testproc(12,89):: Returns错误
Dav*_*sta 10
过程的第二个参数是一个OUT参数 - 它的值将分配给过程完成时传递的变量.因此,您不能为此参数使用文字值.
您可以在SQLPlus提示符下声明一个绑定变量并使用它:
-- Declare bind variable
VARIABLE x NUMBER
-- If necessary, initialize the value of x; in your example this should be unnecessary
-- since the value of the second parameter is never read
EXEC :x := 1
-- Call the procedure
EXEC testproc(12, :x)
-- Print the value assigned to the bind variable
PRINT x
Run Code Online (Sandbox Code Playgroud)
或者,您可以使用匿名PL/SQL块:
-- Activate client processing of dbms_output buffer
SET SERVEROUTPUT ON
-- In anonymous block, declare variable, call procedure, print resulting value
DECLARE
x NUMBER;
BEGIN
testproc(12, x);
dbms_output.put_line( x );
END;
/
Run Code Online (Sandbox Code Playgroud)