table type : 1차원 array 형태를 나타냄, 다중 선언을 통해 array 기능을 만들 수 있음
record type : c언어의 structure 구조를 만드는듯, 기본형만 넣을 수 있는건 아닐테니 다양한 확장이 가능할 꺼 같음
declare
type test_record_type is record(
name varchar2(20)
, email varchar2(20)
);
type test_table_type is table of test_record_type
index by binary_integer;
lt_test test_table_type;
ln_cnt binary_integer := 0;
begin
for fc_tmp in (
with tmp_tab as (
select '이승구' as name, 'id' as email from dual
union
select '이승규' as name, 'id2' as email from dual
union
select '이승기' as name, 'id3' as email from dual
)
select * from tmp_tab
) loop
ln_cnt := ln_cnt + 1;
lt_test(ln_cnt).name := fc_tmp.name;
lt_test(ln_cnt).email := fc_tmp.email;
end loop;
for fn_cnt in 1..ln_cnt loop
dbms_output.put_line('lt_test[' || fn_cnt || '].name : ' || lt_test(fn_cnt).name);
dbms_output.put_line('lt_test[' || fn_cnt || '].email : ' || lt_test(fn_cnt).email);
end loop;
dbms_output.put_line('test');
end;