Oracle Database
Oracle UTL_FILE을 이용한 데이터 loading의 간단한 예제
에너자이죠
2010. 11. 3. 11:59
UTL_FILE을 이용해 file을 loading 하는 아주 간단한 example.
declare
fp utl_file.file_type;
str varchar2(48);
VAL SCOTT.TEST%ROWTYPE;
begin
fp := utl_file.fopen('DATA_PUMP_DIR','sample_data.txt','r');
loop
utl_file.get_line(fp,str);
VAL.CUST_ID := TRIM(SUBSTR(str,1,9));
VAL.FC_ID := TRIM(SUBSTR(str,11,20));
insert into SCOTT.TEST values(VAL.CUST_ID,VAL.FC_ID);
end loop;
exception
when no_data_found then
commit;
end;
/