Oracle中的“批量收集”和“立即执行”
发布时间:2020-12-12 13:49:30 所属栏目:百科 来源:网络整理
导读:是否可以使用oracle中的“execute immediate”命令执行“bulk Collect into”?所有这些都将成为返回管道表的函数的一部分. 是的,从技术上讲,你可以: 1 SQL declare 2 type x is table of t.id%type index by pls_integer; 3 xx x; 4 begin 5 execute immed
是否可以使用oracle中的“execute immediate”命令执行“bulk Collect into”?所有这些都将成为返回管道表的函数的一部分.
是的,从技术上讲,你可以:
1 SQL> declare 2 type x is table of t.id%type index by pls_integer; 3 xx x; 4 begin 5 execute immediate 6 'select id from t' bulk collect into xx; 7 dbms_output.put_line(xx.count); 8 end; 9 / 426 Oracle在文档中明确指出: http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm 但是,如果您真的需要执行动态SQL,那么您可以使用更有用的方式事件 – 弱ref游标.您将可以访问LIMIT这样强大的选项,并且可以使用记录集合. SQL> declare 2 type x is table of t%rowtype index by pls_integer; 3 xx x; 4 c sys_refcursor; 5 begin 6 open c for 'select * from t'; 7 loop 8 fetch c bulk collect into xx limit 100; 9 dbms_output.put_line(xx.count); 10 exit when c%notfound; 11 end loop; 12 close c; 13 end; 14 / 100 100 100 100 26 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |