如何使用 Toad 从 Oracle 中的函数获取返回值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4827134/
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 03:03:18  来源:igfitidea点击:

How do I get the return value from a function in Oracle using Toad

oracletoad

提问by Stagg

How do I find out in Toad what the return value of a function is?

如何在 Toad 中找出函数的返回值是什么?

I'm running something like this code:

我正在运行这样的代码:

declare r number;
begin
    r:= packagename.functionname(paraname);
end;

I can't work out how to get "r" returned to the data grid, some posts suggest using DBMS output but nothing is written to it when I run the code.

我不知道如何将“r”返回到数据网格,一些帖子建议使用 DBMS 输出,但在我运行代码时没有写入任何内容。

The function performs updates, commits, calls other functions and has cursors in it.

该函数执行更新、提交、调用其他函数并在其中包含游标。

回答by Allan

begin
    dbms_output.put_line(packagename.functionname(paraname));
end;

You'll need to turn output on before running this. To do that, select the "DBMS Output" tab at the bottom of the editor, then click the leftmost button under the tab (it should depict a red circle, with the tooltip "Turn Output On" (if it's a green circle, output is already on)).

您需要在运行之前打开输出。为此,请选择编辑器底部的“DBMS 输出”选项卡,然后单击选项卡下最左侧的按钮(它应该描绘一个红色圆圈,带有工具提示“打开输出”(如果是绿色圆圈,则输出已经开启))。

The results of the query will be written to the "DBMS Output" window, not the "Data Grid" (you may have to wait a few seconds for the polling to pick up the results). If you use a user-defined type or a ref cursor, this will be insufficient and you'll need to process the results in the anonymous block before writing them out.

查询的结果将写入“DBMS 输出”窗口,而不是“数据网格”(您可能需要等待几秒钟轮询才能获取结果)。如果您使用用户定义的类型或引用游标,这将是不够的,您需要在将结果写出之前处理匿名块中的结果。

回答by Klaus Byskov Pedersen

How about just:

怎么样只是:

select packagename.functionname(paraname) from dual; 

回答by Andy F

The answer from Klaus of

来自克劳斯的回答

select packagename.functionname(paraname) from dual;

select packagename.functionname(paraname) from dual;

worked for me but it only returned a cursor. This displayed as (CURSOR) in the data grid in Toad. Once I double clicked on that, it opened a new windows with a data grid for that cursor and I saw my results.

对我来说有效,但它只返回一个游标。这在 Toad 的数据网格中显示为 (CURSOR)。一旦我双击它,它就会打开一个带有该光标数据网格的新窗口,我看到了我的结果。