Multiple INTO in SQL Loader
Bharath, June 04, 2002 - 11:50 am UTC
Hi,
Is it necessary to have the clause POSITION(1) from the second INTO TABLE onwards when the control file contains more than one INTO TABLE ststement. In the example given below, If I have POSITION(1) then the data is loaded, if the WHEN condition happens to be valid. But if I remove the POSITION(1), the data is not loaded even if the WHEN condition happens to be valid.
I searched about this in your book, but it was not given. Could you explain the use of POSITION clause in sql loader.
June 05, 2002 - 6:07 am UTC
If you did not use the POSITITION(1), sqlldr would pick off where it left off in the record for the second INTO section.
So, think of the position(1) like a request to "reset record back to the first character". Without it -- you would pick up where you left off
Multiple INTO in SQL Loader
Bharath, June 04, 2002 - 11:51 am UTC
Hi,
Is it necessary to have the clause POSITION(1) from the second INTO TABLE onwards when the control file contains more than one INTO TABLE ststement. In the example given below, If I have POSITION(1) then the data is loaded, if the WHEN condition happens to be valid. But if I remove the POSITION(1), the data is not loaded even if the WHEN condition happens to be valid.
LOAD DATA
INFILE 'DEPT_LOADER.txt'
BADFILE 'DEPT_LOADER.bad'
DISCARDFILE 'DEPT_LOADER.dis'
TRUNCATE
INTO TABLE dept_loader
WHEN (deptno='10')
(
deptno INTEGER EXTERNAL TERMINATED BY ",",
dname CHAR TERMINATED BY "," ENCLOSED BY '"',
loc CHAR TERMINATED BY "," ENCLOSED BY '"'
)
INTO TABLE dept_loader
WHEN (deptno='20')
(
deptno POSITION(1) INTEGER EXTERNAL TERMINATED BY ",",
dname CHAR TERMINATED BY "," ENCLOSED BY '"',
loc CHAR TERMINATED BY "," ENCLOSED BY '"'
)
I searched about this in your book, but it was not given. Could you explain the use of POSITION clause in sql loader.
Regards,
Bharath
Sagi, October 15, 2003 - 3:22 am UTC
Hi Tom,
I have a problem in using WHEN. I am sorry if this is not the correct place to post.
I tried on ur site and could get no break through. So posting.
I have data like this:
/resource/images/learn/side_nav_dictionary-current.gif
/resource/images/learn/side_nav_links.gif
/resource/images/home/link_request.gif
/resource/jsp/common/internalServerError.jsp
/resource/jsp/common/internalServerError.jsp
/resource/jsp/common/internalServerError.jsp
I want to upload this into a table. But ignore .gif and .jpg records
I tried to use SUBSTR in the column_name where this data goes. But sqlldr gives error.
My control file looks like this
load data
infile 'c:\data.txt'
BADFILE 'c:\data.bad'
DISCARDFILE 'c:\data.dsc'
APPEND into table ACCESS_INFO
WHEN SUBSTR(URL,-4,4) != '.gif' AND
SUBSTR(URL,-4,4) != '.jpg'
fields terminated by whitespace OPTIONALLY ENCLOSED BY '"'
(id SEQUENCE(1,1),
URL CHAR(3000) )
Your help is very much apprieciated.
Thanx in advance.
October 15, 2003 - 7:54 am UTC
what version of the database are you using.
Sagi, October 16, 2003 - 1:56 am UTC
Tom,
Sorry forgot to mention about it.
I have this requirement for both 8.1.7 and 9.2.0
Awaiting for your help.
Thanx in advance.
Regards,
October 16, 2003 - 10:27 am UTC
don't think you'll be doing it in sqlldr then -- if you are on unix you can load from a named pipe that you fill with a grep on that file to filter out the rows you don't want loaded.
Sagi, October 16, 2003 - 12:13 pm UTC
Tom,
I have to do this on WIN2K.
But let me understand what you meant. If I was on Unix, then I would do the following:
-- Create a named pipe (Say mypipe)
-- use grep to filter. In my case it would be:
grep -v "*.gif" | mypipe | sqlldr control=myctrl.ctl data=mypipe
Is my understanding right?
Secondly, using CYWIN, can i do from windows machine this?
Thanx in advance.
Regards,
October 16, 2003 - 5:17 pm UTC
in unix i would:
$ mknod input.dat p
$ egrep -v '(.gif$|.jpg$)' > input.dat &
$ sqlldr .... data=input.dat
on windoze, which doesn't do something as cool as pipes, you may well be plumb out of luck. No idea if cywin supports TRUE pipes
Rick Jolley, December 28, 2004 - 3:51 pm UTC
Great help for filtering loads into a table using sqlldr and the WHEN clause. After reading this article, I added POSITION(1) to the first record of the second INTO TABLE statement and everything worked as expected.
That really should be added to the Oracle documentation, or put into an article on metalink. I've seen lots of questions on this issue with no answer.