스 크 립 트 sqlldr ctl 파일 생 성

create_control_extend.sql
set echo off                                     
set heading off                                  
set verify off                                   
set feedback off                                 
set show off                                     
set trim off                                     
set pages 0                                      
set concat on                                    
set lines 300                                    
set trimspool on                                 
set trimout on                                   
spool &1..ctl                                    
select 'LOAD DATA'||chr (10)||             
--       'INFILE '''||lower (table_name)||'.dat '''||
       '&2 into table '||table_name||chr (10)||     
--       'Append into table '||table_name||chr (10)||     
       'FIELDS TERMINATED BY "&3"'|| chr (10)||
       'TRAILING NULLCOLS'||chr (10)||'('        
from   user_tables                                
where  table_name = upper ('&4');                
select decode (rownum, 1, '   ', ' , ')||
       rpad (column_name, 33, ' ')||
       decode (data_type,
               'VARCHAR2', 'CHAR('||RTRIM(TO_CHAR(DATA_LENGTH+4)) ||')  NULLIF ('||column_name||'=BLANKS)'||' "trim(:'||column_name||')"',
               'FLOAT',    'DECIMAL EXTERNAL NULLIF('||column_name||'=BLANKS)',
               'NUMBER',   decode (data_precision, 0,
                           'INTEGER EXTERNAL NULLIF ('||column_name||
                           '=BLANKS)', decode (data_scale, 0,
                           'INTEGER EXTERNAL NULLIF ('||
                           column_name||'=BLANKS)',
                           'DECIMAL EXTERNAL NULLIF ('||
                           column_name||'=BLANKS)')),
               'DATE',     'DATE "YYYY-MM-DD"  NULLIF ('||column_name||'=BLANKS)',
               null)
from   
(select * from user_tab_columns
where  table_name = upper ('&4')
order  by column_id ) t;                           
select ')'                                       
from sys.dual;                                   
spool off 
quit                                      

 스 크 립 트 실행 (autogencrtl. bat)
::     zslp_tl_batch     test.ctrl sqlldr    
::  1=        、  2=truncate|append...  、  3=     、  4=     
sqlplus user/password@dbsid @D:\create_control_extend.sql   test  append "|"  zslp_tl_batch 

좋은 웹페이지 즐겨찾기