Oracle/PL/SQL
15일차 # 6-26: 추가 BULK COLLECT
Bohemian life
2012. 4. 24. 21:36
drop table t1 purge;
create table t1 as select * from emp where 1=2;
------------------------------
declare
TYPE emp_record_table_type IS TABLE OF emp%rowtype
INDEX BY PLS_INTEGER;
n emp_record_table_type;
begin
select * BULK COLLECT into n
from emp
order by sal desc;
for i in n.first .. n.last loop
insert into t1 values n(i);
p(i||' elements');
end loop;
p(n(4).empno||' '||n(4).ename);
end;
/
------------------------------
select * from t1;