Home » RDBMS Server » Server Utilities » How to load multiple files into the database using sql*loader? (Oracle 10g)
How to load multiple files into the database using sql*loader? [message #385816] |
Wed, 11 February 2009 03:32 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear All,
I have small clarification I don't know whether it is possible i have a folder which has 100 datafiles where each datafile is named as 11/2/2009.txt,10/2/2009.txt.... and so on.Where all the datafiles are stored in a particular folder so that each file in the folder should get append to the table on datewise , my concern is whether we need to mention all the datafiles names in the control file or is there any method to load the data by use of sql*loader.
Thanks and Regards,
Hammer
|
|
|
|
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #386614 is a reply to message #385828] |
Mon, 16 February 2009 04:31 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
Thanks for your reply.Can you give me a precise example.Please correct me if i am wrong, does shell scripts syntax vary for different operating system. I have gone through the windows froum but i am not good in shell scripting to dig it up. Can you give me the example syntax to invoke the Oracle Loader into the shell scripting. I don't know whether this is possible, If i have 10 files named 01-JAN-2009.txt,02-JAN-2009.txt....inside a single folder.Inside the control file can i use (like *.txt) so that it will load all the files.
Thanka and Regards,
Hammer.
|
|
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #386766 is a reply to message #386652] |
Mon, 16 February 2009 23:36 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
Google is not broken for me.In Command Prompt when I issue DIR c:\load\*.txt it displays all the text files corresponding to that folder.
C:\>DIR C:\LOAD\*.txt
Volume in drive C has no label.
Volume Serial Number is EC8F-43E0
Directory of C:\LOAD
01/16/2009 04:54 PM 3,852,881 10-JAN-2009.txt
01/16/2009 04:54 PM 3,852,881 load2.txt
01/16/2009 04:54 PM 3,852,881 load3.txt
3 File(s) 11,558,643 bytes
0 Dir(s) 13,988,012,032 bytes free
So in command prompt whether i need to issue the below statement.
c:\dir c:\load\*.txt do sqlldr test/test control=c:\controlfiles\myctl.ctl log=forall.log
Here i have one more clarification what needs to be mention in the infile i am confused in this part.
Thnaks and Regards,
Hammer
|
|
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #386917 is a reply to message #386900] |
Tue, 17 February 2009 04:50 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Hi Michel,
When i issue the command dir /c in command prompt it dispalys all the files like .txt files,.log files and so on.From your post i came to know that since it is windows operating system we need to make use of the batch files to run the task.
correct me if i am wrong, below is my batch file
@echo off
for /f %f in ('dir c:\load\*.txt') do (sqlldr test/test control=c:\controlfiles\load.ctl log=test.log)
eof
So in the above batch file 'dir c:\load\*.txt' this part will give the results of all the file names corresponding to the particular folder and each .txt filename is assigned to the variable %f.But in control file what needs to be mentioned in the infile parameter.
Thanks and Regards,
Hammer
[Updated on: Tue, 17 February 2009 04:54] Report message to a moderator
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #386925 is a reply to message #386920] |
Tue, 17 February 2009 05:16 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
Below is the .bat file i have changed.
@echo off
for /f %f in ('dir c:\load\*.txt') do sqlldr test/test control=c:\controlfiles\load.ctl log=test.log data=%f
eof
My control file looks like below whether i need to mention %f in the infile parameter?
Can you give me a clue.
OPTIONS (ROWS=1000, readsize=12582912, BINDSIZE=12582912, SILENT=FEEDBACK,DISCARDS)
LOAD DATA
infile 'C:\BULK\LOAD1.TXT'
badfile 'C:\BULK\XYZ.BAD'
DISCARDFILE 'C:\BULK\XYZ.DSC'
INSERT INTO TABLE test
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(a,
b,
c,
d,
e,
f,
g,
h)
Thanks and Regards,
Hammer
[Updated on: Tue, 17 February 2009 05:18] Report message to a moderator
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #386948 is a reply to message #386927] |
Tue, 17 February 2009 06:05 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
I think i am near to the results.Below is my batch file.
@echo off
for /f %f in ('dir c:\load\*.txt') do sqlldr test/test control=c:\controlfiles\load.ctl log=test.log data=%f
eof
I named the batch file as test.bat in c drive.
My control file looks like below,
OPTIONS (ROWS=1000, readsize=12582912, BINDSIZE=12582912, SILENT=FEEDBACK,DISCARDS)
LOAD DATA
badfile 'C:\BULK\XYZ.BAD'
DISCARDFILE 'C:\BULK\XYZ.DSC'
INSERT INTO TABLE test
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(a,
b,
c,
d,
e,
f,
g,
h)
when i issue the below command it fetches the results saying that the file exist.
C:\>dir c:\load\*.txt
Volume in drive C has no label.
Volume Serial Number is EC8F-43E0
Directory of c:\load
01/16/2009 04:54 PM 3,852,881 10-JAN-2009.txt
01/16/2009 04:54 PM 3,852,881 load2.txt
01/16/2009 04:54 PM 3,852,881 load3.txt
3 File(s) 11,558,643 bytes
0 Dir(s) 13,715,406,848 bytes free
C:\>
But when i run the batch file test.bat in command prompt it says that the file not found.
C:\>dir c:\load\*.txt
Volume in drive C has no label.
Volume Serial Number is EC8F-43E0
Directory of c:\load
01/16/2009 04:54 PM 3,852,881 10-JAN-2009.txt
01/16/2009 04:54 PM 3,852,881 load2.txt
01/16/2009 04:54 PM 3,852,881 load3.txt
3 File(s) 11,558,643 bytes
0 Dir(s) 13,715,406,848 bytes free
C:\>test.bat
File Not Found
SQL*Loader: Release 10.1.0.2.0 - Production on Tue Feb 17 17:32:54 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (f.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
SQL*Loader: Release 10.1.0.2.0 - Production on Tue Feb 17 17:32:54 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (f.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
SQL*Loader: Release 10.1.0.2.0 - Production on Tue Feb 17 17:32:54 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (f.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
'eof' is not recognized as an internal or external command,
operable program or batch file.
C:\>
Thanks and Regards,
Hammer
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #386962 is a reply to message #386953] |
Tue, 17 February 2009 07:05 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
Sorry that i have posted the wrong .bat file i apoligise for my mistake,actually this is my batch file
@echo off
for /f %%f in ('dir c:\load\*.txt') do (sqlldr test/test control=c:\controlfiles\load.ctl log=c:controlfiles\test.log data=%%f)
But still the same message whether in data=(i need to specify the root path of the datafiles ?).
Thanks and Regards,
Hammer
|
|
|
|
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #387188 is a reply to message #387162] |
Wed, 18 February 2009 03:51 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
I made the below test in command prompt,I used %f directly in the command prompt, for the test purpose I executed directly in the command prompt.Below is the error which i got,this is for your kind reference.
C:\Documents and Settings\Administrator>FOR /F %F IN ('DIR C:\LOAD\*.TXT') DO SQ
LLDR TEST/TEST CONTROL=C:\CONTROLFILES\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DA
TA=C:\LOAD\%F
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\Volume
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:14 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\Volume.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\Volume
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:14 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\Volume.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\Directory
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:15 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\Directory.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\01/16/2009
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:15 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\01/16/2009.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\01/16/2009
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:15 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\01/16/2009.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\2
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:15 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\2.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>SQLLDR TEST/TEST CONTROL=C:\CONTROLFILES
\MYCTL.CTL LOG=C:\CONTROLFILES\TEST.LOG DATA=C:\LOAD\0
SQL*Loader: Release 10.1.0.2.0 - Production on Wed Feb 18 15:17:15 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL*Loader-500: Unable to open file (C:\LOAD\0.dat)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
C:\Documents and Settings\Administrator>
Thanks and Regards,
Hammer
[Updated on: Wed, 18 February 2009 03:55] Report message to a moderator
|
|
|
|
Re: How to load multiple files into the database using sql*loader? [message #387214 is a reply to message #387201] |
Wed, 18 February 2009 05:15 |
aviva4500
Messages: 122 Registered: July 2008 Location: bangalore
|
Senior Member |
|
|
Dear Michel,
1. My text files are located in the folder named LOAD which has two text files with names load2.txt,load3.txt.
C:\Documents and Settings\Administrator>dir c:\load\*.txt
Volume in drive C has no label.
Volume Serial Number is EC8F-43E0
Directory of c:\load
01/16/2009 04:54 PM 3,852,881 load2.txt
01/16/2009 04:54 PM 3,852,881 load3.txt
2 File(s) 7,705,762 bytes
0 Dir(s) 13,762,519,040 bytes free
C:\Documents and Settings\Administrator>
2. When I issue the command in the command prompt whether the particular file exists it was there which was show above.
3. Below is my control file which is named as myctl.ctl which is located in the c drive
C:\Documents and Settings\Administrator>dir c:\controlfiles\myctl.ctl
Volume in drive C has no label.
Volume Serial Number is EC8F-43E0
Directory of c:\controlfiles
02/17/2009 04:53 PM 454 MYCTL.CTL
1 File(s) 454 bytes
0 Dir(s) 13,789,933,568 bytes free
C:\Documents and Settings\Administrator>
4. The content in the control file looks ike below.
OPTIONS (ROWS=1000, readsize=12582912, BINDSIZE=12582912, SILENT=FEEDBACK,DISCARDS)
LOAD DATA
badfile 'C:\BULK\XYZ.BAD'
DISCARDFILE 'C:\BULK\XYZ.DSC'
REPLACE
INTO TABLE PRODUCT
FIELDS TERMINATED BY ''
OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(a,
b,
c,
d,
e,
f,
g..)
5. My data in the text files looks like below.
EX1021 2516800 0 0 0 1307 0 6R LMV LAX 432 22-Dec-07
EX1022 96800 0 0 0 1278 0 6R LMV ONT 432 22-Dec-07
EX1023 290400 0 0 0 1290 0 6R HSV MEX 432 22-Dec-07
EX1024 3194400 0 0 0 1307 0 6R LAX LMV 432 22-Dec-07
EX1025 580800 0 0 0 1553 0 6R MEX LAX 432 22-Dec-07
So the above description is for your kind reference,
I opened the command prompt and issued the below statement.
c:\Documents and Settings\Administrator\>for /f %f in ('dir/b') do sqlldr test/test control=c:\controlfiles\myctl.ctl log=c:\controlfiles\test.log data=c:\load\%f
But when i issue dir/b in the command prompt it displays all the files.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>dir /b
.businessobjects
.WASRegistry
._cie.trace.xml.lck
afiedt.buf
BrioPlatformInstall.log
BrioPlatformInstall.log.0
BrioPlatformInstall.log.1
cogtrwin.ini
Contacts
CONTROL2.log
DDL_LIST.SQL
Desktop
DROP.SQL
Favorites
ismanager_workspace
is_install.rsp
LOAD1.log
LOADALL.LOG
LOADER.log
LOADTEST.LOG
My Documents
OUTPUT_TO_FLAT_FILE.TXT
portdef.props
sqlnet.log
Start Menu
test.ctl
test.dat
TEST.LOG
TEST1.LOG
TEST1.LOG;
test12.log
TEST123.LOG
Tracing
C:\Documents and Settings\Administrator>
Now i have changed to dir/b in the below statement.
c:\Documents and Settings\Administrator\>for /f %f in ('dir/b') do sqlldr test/test control=c:\controlfiles\myctl.ctl log=c:\controlfiles\test.log data=c:\load\%f
Could you correct me where i am missing.
Thanks and Regards,
Hammer
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Dec 23 19:55:02 CST 2024
|