如何迭代 OracleDbType.RefCursor 结果集
我目前在实现从 Oracle 数据库获取数据的 MVC 2 网站时遇到了一些困难...现在我想迭代 RefCursor 输出参数,然后抛出所有结果并将其序列化为自定义的 xml字符串...
我是否遗漏了有关 RefCursor 的某些内容?因为在做了一些研究之后,似乎没有办法循环抛出所有返回的行和列。我知道你可以从 RefCursor 获得 DataReader...但是 DataReader 似乎有点令人困惑。我只想浏览返回的数据集的所有行和列...我希望存储过程设计器只返回结果集,而不是将其放入一个奇怪的引用游标中。我相信她有她的理由。
这个问题确实看起来有点布什联盟,我将继续研究做到这一点的最佳方法。感谢您提供的任何信息...此外,我愿意以完全不同的方式做到这一点。我并不特别热衷于任何一种循环引用光标的方式。
PS 看起来我在代码中使用了折旧方式。关于如何使用 ODP.Net 做到这一点有什么想法吗?
I am currently a little stuck right now in my implementation of MVC 2 website that gets data from an Oracle Database... Right now I want to Iterate through a RefCursor out parameter and go threw all of the results and serialize it into a customized xml string...
Am I missing something about RefCursor? Because after doing some resesarch there doesn't seem to be a way to loop throw all the returned Rows and Columns. I know you can get a DataReader from a RefCursor... But DataReader seems to be somewhat confusing. I just want to go through all the rows and columns of the returned data set... I wish the stored proc designer would have just returned the result set instead of placing it into a freaking Ref Cursor. I am sure she had her reasons though.
This question does seem a little bush league and I will continue to research the best way to do this. Thanks for any information that you can give... Also, I am open to doing this in a completely different way. I am not particularly wedded to any one way of looping through the ref cursor.
P.S Looks like I was using the depreciated way in my code. Any idea on how to do it using ODP.Net?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个链接: http://www.akadia.com/services/ora_return_result_set.html 给出您想要的答案。您使用数据适配器用函数的引用游标结果“填充”数据表。然后您可以迭代数据表。
尽管仔细观察,我没有看到作者如何在“out”refcursor 参数和映射“emp”的表之间建立关联。
I think this link: http://www.akadia.com/services/ora_return_result_set.html gives the answer you want. You use a dataadapter to 'fill' a datatable with the refcursor result of the function. Then you can iterate over the datatable.
Although looking at it closer I don't see how the author makes an associate between the 'out' refcursor parameter and the table mapping 'emp'.