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

发布于 2024-10-15 06:34:52 字数 248 浏览 7 评论 0原文

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

我正在运行类似这样的代码:

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

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

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

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

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素食主义者 2024-10-22 06:34:52
begin
    dbms_output.put_line(packagename.functionname(paraname));
end;

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

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

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)).

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.

满身野味 2024-10-22 06:34:52

怎么样:

select packagename.functionname(paraname) from dual; 

How about just:

select packagename.functionname(paraname) from dual; 
叹倦 2024-10-22 06:34:52

克劳斯的回答

从 Dual 中选择 packagename.functionname(paraname);

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

The answer from Klaus of

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文