在 R 中调用 Oracle 存储过程 - 如何获取结果集?
寻找使用 R 调用 Oracle 存储过程并返回结果集的示例。
我使用 RJDBC 库 dbGetQuery 来调用 Sybase procs 并将结果指向变量,这对于 Oracle select stmts 的工作原理相同。但是,我不知道如何让它从 Oracle 存储过程(即从 sys_refcursor 输出参数)返回 Oracle 结果集。我找到的从 Oracle 检索数据的唯一示例涉及“从表中选择列”。
在 google 中搜索后,我找到了“dbCallProc – 调用 SQL 存储过程”,这听起来很有希望,但我发现的每个参考文献都表明它“尚未实现”。 >"
有使用过程的指针或示例吗?非常赞赏。不知道为什么 Oracle 在检索结果集时总是遇到这样的挑战......
谢谢, Mike
更新:我举一个简单地调用 Oracle 存储过程的例子。 RJDBC 目前不支持 Oracle 过程吗?
Looking for an example for calling Oracle stored proc using R, and returning a result set.
I'm using RJDBC library, dbGetQuery to call Sybase procs and point the results to a variable, and this works the same for Oracle select stmts. However, I don't see how to get this to return Oracle result sets from an Oracle stored proc (i.e., from the sys_refcursor out param). The only examples I find for retrieving data from Oracle involve "select columns from table".
Searching in google was led me to "dbCallProc – Call an SQL stored procedure" which sounds very promising, but every ref I found to it indicates that it is "Not yet implemented."
Any pointers or examples for using procs? Greatly appreciated. Don't know why Oracle always has to be such a challenge for retrieving result sets....
Thanks,
Mike
UPDATE: I'd take an example that simply called an Oracle stored proc. Are Oracle procs simply not supported currently in RJDBC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法专门帮助您使用 R,但您说您在调用使用 OUT 参数作为 sys_refcursors 的 Oracle 过程时遇到问题。您还指出此功能可能尚未实现。但是,您确实说您可以“从表中选择列”。
因此,我建议将过程更改为管道函数调用,然后执行简单的选择以从 Oracle 获取数据。一个小例子:
包体:
用法:
或者:
这将返回 3 行数据,就像过程返回相同的数据一样。只有这样你才能从 select 语句中获取它(你似乎可以从 R 中处理它)。
希望有帮助。
I can't help you specifically with R, but you say you're having issues in calling Oracle procedures that use OUT params as sys_refcursors. You also indicate this ability may not be implemented yet. You do say, however, that you can "select columns from table" just fine.
So, I propose changing the procedures to pipelined function calls, and then doing a simple select to get your data from Oracle. A small example:
The package body:
Usage:
Or:
This would return 3 rows of data, just as a procedure would return the same data. Only this way you can get it from a select statement (which you seem to be able to handle from R).
Hope that helps.