oracle 从存储过程中检索参数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14649657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:49:50  来源:igfitidea点击:

retrieve out parameter from stored procedure?

oracleplsql

提问by Thiyagu ATR

I have created one stored procedurein oracle:

我 在 oracle 中创建了一个存储过程

PROCEDURE string_opp(input_string IN varchar2,output_string OUT varchar2)

Now the problem is how to execute this stored procedure and retrieve the output parameter.i've followed in sql developer:

现在的问题是如何执行此存储过程并检索输出参数。我在 sql developer 中遵循:

SET SERVEROUTPUT ON
DECLARE
  outputString VARCHAR;
BEGIN
  EXEC string_opp('input String',:outputString);
END;

When i tried this i didn't get anything, could someone help me?

当我尝试这个时我没有得到任何东西,有人可以帮助我吗?

采纳答案by gustavodidomenico

Just a couple of issues:

只是几个问题:

SET SERVEROUTPUT ON
DECLARE
   outputString VARCHAR(20);
BEGIN
  string_opp('input String', outputString);
  dbms_output.put_line(outputString);
END;

You can use as the same variable:

您可以使用相同的变量:

SET SERVEROUTPUT ON
DECLARE
   outputString VARCHAR(20);
BEGIN
  outputString := 'input String';
  string_opp(outputString);
  dbms_output.put_line(outputString);
END;

Just define your procedure parameter as IN OUT in place of just OUT.

只需将过程参数定义为 IN OUT 而不是 OUT。

Check this resource:

检查此资源:

http://psoug.org/snippet/FUNCTIONS-IN-OUT-parameter_873.htm

http://psoug.org/snippet/FUNCTIONS-IN-OUT-parameter_873.htm

回答by user2001117

Let say:

让说:

If you have Store procedure with output parameter:

如果您有带输出参数的存储过程:

Create procedure test(name out varchar2(50))
as
begin
name:='testing output parameter';
-- dbms_output.put_line('Output parameter value ' || name );
end;

Now execute the above procedure :

现在执行上面的程序:

declare
l_name varchar2(50);
begin
test(l_name);
dbms_output.put_line( 'name = ' || l_ename );
end;