使用参考光标作为 ODP.NET 的输入类型
我正在尝试使用 RefCursor
作为 Oracle 存储过程的输入参数。 这个想法是选择一组记录,将它们输入到存储过程中,然后 SP 循环输入RefCursor
,对其记录执行一些操作。 不,我无法选择 SP 内的记录,从而避免使用 RefCursor
作为输入类型。
我在 Oracle 文档中找到了一个关于如何执行此操作的示例(这将是链接,但似乎我还无法使用它们),但它使用简单的 SELECT
来填充输入 <代码>参考光标; 这就是问题所在:我必须从代码中填充它。
你看,在代码中我有这样的:
[OracleDataParameter("P_INPUT", OracleDbType.RefCursor, ParameterDirection.Input)]
private List<MiObject> cursor;
而且,我尝试用 List
、DataTable
甚至一个 cursor 填充 cursor MyObject
的普通数组,没有任何效果。 当我尝试运行测试时出现错误:
“参数链接无效”
也许不是确切的措辞,因为我是从西班牙语翻译的,但这就是消息
有什么想法吗?
I'm trying to use a RefCursor
as an input parameter on an Oracle stored procedure. The idea is to select a group of records, feed them into the stored procedure and then the SP loops over the input RefCursor
, doing some operations to its records. No, I can't select the records inside the SP and thus avoid having to use the RefCursor
as an input type.
I've found an example on how to do this on (this here would be the link, but it seems I cannot use them yet) Oracle's documentation, but it uses a simple SELECT
to populate the input RefCursor
; and therein lies the rub: I've got to populate it from code.
You see, in code I have this:
[OracleDataParameter("P_INPUT", OracleDbType.RefCursor, ParameterDirection.Input)]
private List<MiObject> cursor;
And, I've tried populating cursor with a List<T>
, a DataTable
, even an plain array of MyObject
, and nothing works. When I try running my tests I get an error:
"Invalid Parameter Linking"
Maybe not the exact wording, as I'm translating from Spanish, but that's the message
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 此示例,将 refcursor 作为 pl 的输入/sql 来自 Oracle Technet。
要点是输入refcursor对象必须由oracle自己创建。 您不能将列表或其他任何内容转换为引用游标。
Look at this sample for refcursor as input to pl/sql from oracle technet.
The clou is that the input refcursor object must be created by oracle themself. You cannot convert a list or anything else to refcursor.
根据我的记忆,ODP.NET 库中是否有一个可以运行的
OracleCursor
类?From memory, isn't there an
OracleCursor
class somewhere in the ODP.NET library that works?我还与马克·威廉姆斯(Mark Williams)保持联系,他是我试图在我的帖子上链接的文章的作者,他的回应如下:
“
给我发邮件没问题; 然而,我想我对这个问题的回答会让你失望的。
不幸的是,您无法做您想做的事情(像这样从客户端创建一个引用器)。
这样做的几个问题是,引用游标引用服务器上 Oracle 拥有的内存,而 Oracle 没有诸如 DataTable 或 .NET 列表等客户端项的概念。
除了使用引用游标之外,您还有其他可用选项吗? ?
“
所以基本上我完蛋了,这个问题已经结束了。感谢你们所有人的阅读和/或试图提供帮助。
I'm also in contact with Mark Williams, the author of the article I've tried to link on my post, and he has kinly responded like this:
"
It is no problem to send me email; however, I think I will disappoint you with my answer on this one.
Unfortunately you can't do what you are trying to do (create a refcursor from the client like that).
A couple of problems with that are that a refcursor refers to memory owned by Oracle on the server and Oracle has no concept of client items like a DataTable or a .NET List, etc.
Do you have any other options available other than using a refcursor?
"
So basically I'm screwed, and this question is closed. Thanks for reading and/or trying to help, you all.