[답변][PLSQL] 질문 좀 드리겠습니다. 0 0 1,963

by 백해현 [2008.02.04 11:00:20]


ㅎㅎ

마침 아침에 제가 테스트 한것 하고 똑같네욤

 

create or replace package zz_phh_test
is
  type type_item        is record
  (
    item_id             number
  , item_name           varchar2(60)
  ) ;
 
  type set_item         is table of type_item INDEX BY PLS_INTEGER;

  type type_item_set    is record
  (
    item_id             number
  , item_name           varchar2(60)
  ) ;
  type set_item_set     is table of type_item_set INDEX BY PLS_INTEGER;

  procedure main;   
end zz_phh_test ;


create or replace package body zz_phh_test
is
procedure main
is

  ret_item      set_item     ;
  ret_item_set  set_item_set ;
   
  cursor cur_data is
  select item_id, item_name
    from idb_item_master
   where product_type = 'SET'
  ;
      
begin
 
  open  cur_data ;
  fetch cur_data bulk collect into ret_item ;
  close cur_data ;
 
  for x in ret_item.first..ret_item.last loop
    ret_item_set(x).item_id   := ret_item(x).item_id ;
    ret_item_set(x).item_name := ret_item(x).item_name ;
  end loop ;

 

  for inx in 1..ret_item_set.count loop   
   insert into zz_phh values(ret_item_set(inx).item_id, ret_item_set(inx).item_Name);
  end loop ;  
  commit; 
exception
    when others then
        rollback;
        raise_application_error( -20200, sqlerrm ) ;
end main ;

end zz_phh_test ;

 

 

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입