Home » Infrastructure » Windows » SQLLDR
SQLLDR [message #560052] |
Tue, 10 July 2012 04:33 |
|
bhibe_17
Messages: 24 Registered: July 2012
|
Junior Member |
|
|
hi,
im getting an error message:
SQL*Loader-503: Error appending extension to file (%%g)
OSD-04503: Message 4503 not found; No message file for product=RDBMS, facility=SOSD
when i tried to create a bat file that should read and load all files in the folder specified.
here's my code:
@echo off
for /r c:\bret\infile %%g in (*) Do (
echo Load Data>loaderhdr.ctl
echo INFILE '%%g'>>loaderhdr.ctl
echo append into table INTR_INS_BRET_HDR WHEN (1:1) = "H" >>loaderhdr.ctl
echo (TRANS_ID "intr_ins_bret_hdr_seq.nextval",PROCESS_DATE "to_date(SYSDATE)", REC_TYPE position(1:1^), VERSION_NO position(2:4^), FILE_NAME position(5:44^), FILE_DATE position(45:52^), FILE_NO position(53:54^), PROCESS_TYPE position(55:55^), MERCHANT_NO position(56:70^), FILE_FORMAT_ID position(71:74^), REC_TYPE2 position(75:76^), BATCH_NO position(77:85^), DATE_SENT position(86:91^), TOT_NO_TRANS position(92:95^), SIGN_TOT_BILL_AMT position(105:105^), TOT_BILL_AMT position(96:104^) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)", ESTABLISH_NO position(106:116^), INS_CODE position(117:121^), INS_TYPE position(122:122^)) >> loaderhdr.ctl
call loaddatahdr.bat
)
the program should create a CTL file based on the files inside c:\bret\infile, but its getting an error. appreciate your help. thanks!
|
|
|
Re: SQLLDR [message #560061 is a reply to message #560052] |
Tue, 10 July 2012 05:15 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Rewritten and reformatted (so that you'd actually see what you are doing): TEST.BAT:
for /f %%g in (infile.txt) Do (
echo Load Data > loaderhdr.ctl
echo INFILE '%%g' >> loaderhdr.ctl
echo append into table INTR_INS_BRET_HDR WHEN (1:1^) = 'H' >> loaderhdr.ctl
echo ( TRANS_ID "intr_ins_bret_hdr_seq.nextval" >> loaderhdr.ctl
echo , PROCESS_DATE "to_date(SYSDATE)" >> loaderhdr.ctl
echo , REC_TYPE position(1:1^) >> loaderhdr.ctl
echo , VERSION_NO position(2:4^) >> loaderhdr.ctl
echo , FILE_NAME position(5:44^) >> loaderhdr.ctl
echo , FILE_DATE position(45:52^) >> loaderhdr.ctl
echo , FILE_NO position(53:54^) >> loaderhdr.ctl
echo , PROCESS_TYPE position(55:55^) >> loaderhdr.ctl
echo , MERCHANT_NO position(56:70^) >> loaderhdr.ctl
echo , FILE_FORMAT_ID position(71:74^) >> loaderhdr.ctl
echo , REC_TYPE2 position(75:76^) >> loaderhdr.ctl
echo , BATCH_NO position(77:85^) >> loaderhdr.ctl
echo , DATE_SENT position(86:91^) >> loaderhdr.ctl
echo , TOT_NO_TRANS position(92:95^) >> loaderhdr.ctl
echo , SIGN_TOT_BILL_AMT position(105:105^) >> loaderhdr.ctl
echo , TOT_BILL_AMT position(96:104^) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)" >> loaderhdr.ctl
echo , ESTABLISH_NO position(106:116^) >> loaderhdr.ctl
echo , INS_CODE position(117:121^) >> loaderhdr.ctl
echo , INS_TYPE position(122:122^) >> loaderhdr.ctl
echo ^) >> loaderhdr.ctl
call loaddatahdr.bat
)
The above script seems to be *working* OK.
In my example: INFILE.TXT:
LOADDATAHDR.BAT:
Execution:
M:\>test
M:\>for /F %g in (infile.txt) Do (
echo Load Data 1>loaderhdr.ctl
echo INFILE '%g' 1>>loaderhdr.ctl
echo append into table INTR_INS_BRET_HDR WHEN (1:1) = 'H' 1>>loaderhdr.ctl
echo ( TRANS_ID "intr_ins_bret_hdr_seq.nextval" 1>>loaderhdr.ctl
echo , PROCESS_DATE "to_date(SYSDATE)" 1>>loaderhdr.ctl
echo , REC_TYPE position(1:1) 1>>loaderhdr.ctl
echo , VERSION_NO position(2:4) 1>>loaderhdr.ctl
echo , FILE_NAME position(5:44) 1>>loaderhdr.ctl
echo , FILE_DATE position(45:52) 1>>loaderhdr.ctl
echo , FILE_NO position(53:54) 1>>loaderhdr.ctl
echo , PROCESS_TYPE position(55:55) 1>>loaderhdr.ctl
echo , MERCHANT_NO position(56:70) 1>>loaderhdr.ctl
echo , FILE_FORMAT_ID position(71:74) 1>>loaderhdr.ctl
echo , REC_TYPE2 position(75:76) 1>>loaderhdr.ctl
echo , BATCH_NO position(77:85) 1>>loaderhdr.ctl
echo , DATE_SENT position(86:91) 1>>loaderhdr.ctl
echo , TOT_NO_TRANS position(92:95) 1>>loaderhdr.ctl
echo , SIGN_TOT_BILL_AMT position(105:105) 1>>loaderhdr.ctl
echo , TOT_BILL_AMT position(96:104) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)" 1>>loaderhdr.ctl
echo , ESTABLISH_NO position(106:116) 1>>loaderhdr.ctl
echo , INS_CODE position(117:121) 1>>loaderhdr.ctl
echo , INS_TYPE position(122:122) 1>>loaderhdr.ctl
echo ) 1>>loaderhdr.ctl
call loaddatahdr.bat
)
M:\>(
echo Load Data 1>loaderhdr.ctl
echo INFILE 'test1.csv' 1>>loaderhdr.ctl
echo append into table INTR_INS_BRET_HDR WHEN (1:1) = 'H' 1>>loaderhdr.ctl
echo ( TRANS_ID "intr_ins_bret_hdr_seq.nextval" 1>>loaderhdr.ctl
echo , PROCESS_DATE "to_date(SYSDATE)" 1>>loaderhdr.ctl
echo , REC_TYPE position(1:1) 1>>loaderhdr.ctl
echo , VERSION_NO position(2:4) 1>>loaderhdr.ctl
echo , FILE_NAME position(5:44) 1>>loaderhdr.ctl
echo , FILE_DATE position(45:52) 1>>loaderhdr.ctl
echo , FILE_NO position(53:54) 1>>loaderhdr.ctl
echo , PROCESS_TYPE position(55:55) 1>>loaderhdr.ctl
echo , MERCHANT_NO position(56:70) 1>>loaderhdr.ctl
echo , FILE_FORMAT_ID position(71:74) 1>>loaderhdr.ctl
echo , REC_TYPE2 position(75:76) 1>>loaderhdr.ctl
echo , BATCH_NO position(77:85) 1>>loaderhdr.ctl
echo , DATE_SENT position(86:91) 1>>loaderhdr.ctl
echo , TOT_NO_TRANS position(92:95) 1>>loaderhdr.ctl
echo , SIGN_TOT_BILL_AMT position(105:105) 1>>loaderhdr.ctl
echo , TOT_BILL_AMT position(96:104) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)" 1>>loaderhdr.ctl
echo , ESTABLISH_NO position(106:116) 1>>loaderhdr.ctl
echo , INS_CODE position(117:121) 1>>loaderhdr.ctl
echo , INS_TYPE position(122:122) 1>>loaderhdr.ctl
echo ) 1>>loaderhdr.ctl
call loaddatahdr.bat
)
M:\>echo Here I am!
Here I am!
M:\>pause
Press any key to continue . . .
M:\>(
echo Load Data 1>loaderhdr.ctl
echo INFILE 'test2.csv' 1>>loaderhdr.ctl
echo append into table INTR_INS_BRET_HDR WHEN (1:1) = 'H' 1>>loaderhdr.ctl
echo ( TRANS_ID "intr_ins_bret_hdr_seq.nextval" 1>>loaderhdr.ctl
echo , PROCESS_DATE "to_date(SYSDATE)" 1>>loaderhdr.ctl
echo , REC_TYPE position(1:1) 1>>loaderhdr.ctl
echo , VERSION_NO position(2:4) 1>>loaderhdr.ctl
echo , FILE_NAME position(5:44) 1>>loaderhdr.ctl
echo , FILE_DATE position(45:52) 1>>loaderhdr.ctl
echo , FILE_NO position(53:54) 1>>loaderhdr.ctl
echo , PROCESS_TYPE position(55:55) 1>>loaderhdr.ctl
echo , MERCHANT_NO position(56:70) 1>>loaderhdr.ctl
echo , FILE_FORMAT_ID position(71:74) 1>>loaderhdr.ctl
echo , REC_TYPE2 position(75:76) 1>>loaderhdr.ctl
echo , BATCH_NO position(77:85) 1>>loaderhdr.ctl
echo , DATE_SENT position(86:91) 1>>loaderhdr.ctl
echo , TOT_NO_TRANS position(92:95) 1>>loaderhdr.ctl
echo , SIGN_TOT_BILL_AMT position(105:105) 1>>loaderhdr.ctl
echo , TOT_BILL_AMT position(96:104) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)" 1>>loaderhdr.ctl
echo , ESTABLISH_NO position(106:116) 1>>loaderhdr.ctl
echo , INS_CODE position(117:121) 1>>loaderhdr.ctl
echo , INS_TYPE position(122:122) 1>>loaderhdr.ctl
echo ) 1>>loaderhdr.ctl
call loaddatahdr.bat
)
M:\>echo Here I am!
Here I am!
M:\>pause
Press any key to continue . . .
M:\>
LOADERHDR.CTL:Load Data
INFILE 'test2.csv'
append into table INTR_INS_BRET_HDR WHEN (1:1) = 'H'
( TRANS_ID "intr_ins_bret_hdr_seq.nextval"
, PROCESS_DATE "to_date(SYSDATE)"
, REC_TYPE position(1:1)
, VERSION_NO position(2:4)
, FILE_NAME position(5:44)
, FILE_DATE position(45:52)
, FILE_NO position(53:54)
, PROCESS_TYPE position(55:55)
, MERCHANT_NO position(56:70)
, FILE_FORMAT_ID position(71:74)
, REC_TYPE2 position(75:76)
, BATCH_NO position(77:85)
, DATE_SENT position(86:91)
, TOT_NO_TRANS position(92:95)
, SIGN_TOT_BILL_AMT position(105:105)
, TOT_BILL_AMT position(96:104) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)"
, ESTABLISH_NO position(106:116)
, INS_CODE position(117:121)
, INS_TYPE position(122:122)
)
Now, I'm not loading anything so there might be an error in the control file itself, but - as far as the batch scripting is concerned - that seems to be OK.
Before posting your next message, please, have a look here which will teach you how to properly post your code (and make it easier to read).
[Updated on: Tue, 10 July 2012 05:16] Report message to a moderator
|
|
|
|
|
|
Re: SQLLDR [message #560157 is a reply to message #560152] |
Wed, 11 July 2012 00:48 |
|
bhibe_17
Messages: 24 Registered: July 2012
|
Junior Member |
|
|
Hi littlefoot, Barbara,
i write this code and double-click the BAT File and it worked!
Really appreciate your help guys! Big thanks to both of you!
@echo off
for /r c:\bret\infile %%g in (*.BRET) Do (
echo Load Data> loaderhdr.ctl
echo INFILE '%%g'>> loaderhdr.ctl
echo append into table INTR_INS_BRET_HDR WHEN (1:1^) = "H" >> loaderhdr.ctl
echo (TRANS_ID "intr_ins_bret_hdr_seq.nextval" >> loaderhdr.ctl
echo , PROCESS_DATE "to_date(SYSDATE)" >> loaderhdr.ctl
echo , REC_TYPE position(1:1^) >> loaderhdr.ctl
echo , VERSION_NO position(2:4^) >> loaderhdr.ctl
echo , FILE_NAME position(5:44^) >> loaderhdr.ctl
echo , FILE_DATE position(45:52^) >> loaderhdr.ctl
echo , FILE_NO position(53:54^) >> loaderhdr.ctl
echo , PROCESS_TYPE position(55:55^) >> loaderhdr.ctl
echo , MERCHANT_NO position(56:70^) >> loaderhdr.ctl
echo , MERCHANT_NAME "func_merchant_name(:MERCHANT_NO)" >> loaderhdr.ctl
echo , FILE_FORMAT_ID position(71:74^) >> loaderhdr.ctl
echo , REC_TYPE2 position(75:76^) >> loaderhdr.ctl
echo , BATCH_NO position(77:85^) >> loaderhdr.ctl
echo , DATE_SENT position(86:91^) >> loaderhdr.ctl
echo , TOT_NO_TRANS position(92:95^) >> loaderhdr.ctl
echo , SIGN_TOT_BILL_AMT position(105:105^) >> loaderhdr.ctl
echo , TOT_BILL_AMT position(96:104^) "decode(:sign_tot_bill_amt, '+', :TOT_BILL_AMT/100, :TOT_BILL_AMT/100*-1)" >> loaderhdr.ctl
echo , ESTABLISH_NO position(106:116^) >> loaderhdr.ctl
echo , INS_CODE position(117:121^) >> loaderhdr.ctl
echo , INS_TYPE position(122:122^) >> loaderhdr.ctl
echo ^) >> loaderhdr.ctl
call loaddatahdr.bat
)
|
|
|
|
|
Goto Forum:
Current Time: Wed Dec 11 15:05:42 CST 2024
|