-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathbulk-collect-1.sql
More file actions
89 lines (58 loc) · 1.2 KB
/
Copy pathbulk-collect-1.sql
File metadata and controls
89 lines (58 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
-- bulk-collect-1.sql
-- fetch ... bulk collect into demo
set serveroutput on size unlimited
alter session set plsql_optimize_level=3;
--alter session set Plsql_Warnings = 'error:all';
alter session set Plsql_Warnings = 'enable:all';
/*
maxrc can be altered at runtime
begin
bc.maxrc := 1000;
bc.main;
end;
/
*/
create or replace package bc authid definer
is
maxrc integer := 100;
procedure main;
end;
/
show errors package bc
create or replace package body bc
is
type objrec_t is table of dba_objects%rowtype index by binary_integer;
cursor c1 is select * from dba_objects;
objects objrec_t;
rowcount integer := 0;
procedure p(v_in varchar2)
is
begin
dbms_output.put(v_in);
end;
procedure pl(v_in varchar2)
is
begin
p(v_in);
dbms_output.new_line;
end;
procedure main
is
curr_rows integer := 0;
begin
open c1;
loop
fetch c1 bulk collect into objects limit maxrc;
exit when c1%notfound;
pl('rows fetched: ' || to_char(c1%rowcount - curr_rows));
curr_rows := c1%rowcount;
end loop;
pl('rows fetched: ' || to_char(c1%rowcount - curr_rows));
pl('rowcount: ' || to_char(c1%rowcount));
close c1;
end;
begin
main;
end;
/
show errors package body bc