大佬教程收集整理的这篇文章主要介绍了来自Odp.net中Oracle的多个结果集,没有refcursors,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
SELEct a,b,c from y; select d,e,f from z;
Oracle不喜欢这种语法.可以使用引用游标,如下所示:
begin open :1 for SELEct count(*) from a; open :2 for SELEct count(*) from b; end;
但是,您在打开/关闭游标时会受到惩罚,并且您可以长时间保持数据库锁定.我想做的是使用Odp.net一次性检索这两个查询的结果.可能吗?
因此,如果数据量很小,您可能希望调用只返回值的过程.
如果数据量很大(数千行),那么它无论如何也不会是单个网络旅行,因此当你在游标之间切换时,额外的一两个不会产生太大的影响.
另一种选择是单个选择返回所有行.这可能是一个简单的union all
SELEct a,c from y union all SELEct d,f from z;
它可以是流水线表功能
create or replace package test_pkg is type rec_two_cols is record (col_a varchar2(100),col_b varchar2(100)); type tab_two_cols is table of rec_two_cols; function ret_two_cols return tab_two_cols pipelined; end; / create or replace package body test_pkg is function ret_two_cols return tab_two_cols pipelined is cursor c_1 is SELEct 'type 1' col_a,object_name col_b from user_objects; cursor c_2 is SELEct 'type 2' col_a,object_name col_b from user_objects; r_two_cols rec_two_cols; begin for c_rec in c_1 loop r_two_cols.col_a := c_rec.col_a; r_two_cols.col_b := c_rec.col_b; pipe row (r_two_cols); end loop; for c_rec in c_2 loop r_two_cols.col_a := c_rec.col_a; r_two_cols.col_b := c_rec.col_b; pipe row (r_two_cols); end loop; return; end; end; / SELEct * FROM table(test_pkg.ret_two_cols);
我相信最新版本的ODP for 11g允许用户定义的类型可能有所帮助.
以上是大佬教程为你收集整理的来自Odp.net中Oracle的多个结果集,没有refcursors全部内容,希望文章能够帮你解决来自Odp.net中Oracle的多个结果集,没有refcursors所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。