눈바래다

shell 에서 sqlldr 사용하기


export ctlfile=hist_${JOB_DATE}.ctl

echo "load data"                                                  > $ctlfile

echo "infile $file"                                                  >> $ctlfile

echo "badfile ${file}.bad"                                           >> $ctlfile

echo "append"                                                    >> $ctlfile

echo "into table hist_tmp"                                          >> $ctlfile

echo "( actv_date    position(34:47)  date \"yyyymmddhh24miss\"," >> $ctlfile

echo "  ent_seq_no   sequence(${seq_no},1),"                      >> $ctlfile

echo "  ban          position(25:33)   integer external,"            >> $ctlfile

echo "  oper_id      position(01:07)   integer external,"             >> $ctlfile

echo "  imq_mac_addr position(08:24)   char nullif imq_mac_addr = '@@         '," >> $ctlfile

echo "  org_id       position(48:54)   integer external,"             >> $ctlfile

echo "  window_name  position(55:114)  char,"                     >> $ctlfile

echo "  ctn          position(115:125) char,"                       >> $ctlfile

echo "  model_id     position(126:129) integer external,"            >> $ctlfile

echo "  msn          position(130:149) char,"                      >> $ctlfile

echo "  log_ind      position(150:150) char,"                       >> $ctlfile

echo "  dealer_code  position(151:157) char)"                       >> $ctlfile


sqlldr control=$ctlfile userid=$ORA_USER/$ORA_PASS@$ORA_INST