Oracle/PL/SQL
15일차 # 6-20: Using Collection Methods
Bohemian life
2012. 4. 24. 21:35
참고 : http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/collections.htm#sthref1123
* element 중간에 값이 빠졌을 경우 해결 방법
declare
TYPE number_table_type IS TABLE OF number
INDEX BY PLS_INTEGER;
n number_table_type;
begin
n(8) := 800;
n(3) := 300;
p(n.count);
p(n.first);
p(n.last);
for i in n.first .. n.last loop
p(n(i));
end loop;
end;
/
↓ ↓ ↓
declare
TYPE number_table_type IS TABLE OF number
INDEX BY PLS_INTEGER;
n number_table_type;
cnt number;
begin
n(8) := 800;
n(3) := 300;
n(6) := 600;
cnt := n.first;
while cnt is not null loop --> not null 조건에 유의
p(n(cnt));
cnt := n.next(cnt); --> collection method NEXT
end loop;
end;
/