是否有可能执行"bulk Collect into"与"execute immediate"在Oracle的命令?所有这些都将成为返回管道表的函数的一部分.
是的,从技术上讲,你可以:
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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19470 次 |
| 最近记录: |