Hi,
How do I load records using sql loader using a specified criteria.
I have a table test with a region column. I want to load only those records which belong to certain regions and discard the rest of them.
For example I want to load records belonging to regions
'REGROLL' and 'WWF'.
I created a control file as followed
oad data
infile 'test.txt'
badfile 'ofasweb.bad'
discardfile 'ofasweb.dcs'
truncate
into table test when (REGION IN ('REGROLL','WWF'))
(company position(01:10) char,
time position(11:20) char,........................................
.................................................
But it gives a syntax error.
C:\ofus>sqlldr parfile=parfile.par
SQL*Loader: Release 8.1.7.0.0 - Production on Tue Jun 12 11:50:43 2001
(c) Copyright 2000 Oracle Corporation. All rights reserved.
SQL*Loader-350: Syntax error at line 6.
Expecting = or "<>", found "IN".
into table test when (REGION IN ('REGROLL','WWF'))
But if I create the control file as
load data
infile 'test.txt'
badfile 'ofasweb.bad'
discardfile 'ofasweb.dcs'
truncate
into table test when REGION = 'REGROLL'.............................
...............................
it takes it. Is there any way i can specify multiple values for the same column to filter by.
Thanks
Anurag
Appreciation is a wonderful thing;
It makes what is excellent in others belong to us as well.
Originally posted by tomate test following
into table test when REGION = 'REGROLL' and REGION ='WWF'
I tried that also but it discards teh records
The following is logged into the log file
Record 1: Discarded - failed all WHEN clauses.
Record 2: Discarded - failed all WHEN clauses.
Record 3: Discarded - failed all WHEN clauses.
Record 4: Discarded - failed all WHEN clauses.
Record 5: Discarded - failed all WHEN clauses.
Record 6: Discarded - failed all WHEN clauses.
Record 7: Discarded - failed all WHEN clauses.
Record 8: Discarded - failed all WHEN clauses.
......................................
.........................
Unfortunately SQL*LOader doesn't allow OR operator in the WHEN clause. Multiple conditions can only be applied with AND operator (sigh).
What you can do is to use multiple INTO TABLE clauses in a single controlfile to mimic the behavior of OR conditions, like:
load data
infile 'test.txt'
badfile 'ofasweb.bad'
discardfile 'ofasweb.dcs'
truncate
into table test when REGION = 'REGROLL'
(company position(01:10) char,
time position(11:20) char,........................................)
into table test when REGION = 'WWF'
(company position(01:10) char,
time position(11:20) char,........................................)
Jurij Modic ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Bookmarks