Home » SQL & PL/SQL » SQL & PL/SQL » Eliminating duplicate rows while using SQL loader
Eliminating duplicate rows while using SQL loader [message #157041] Mon, 30 January 2006 22:47 Go to next message
rjanaki
Messages: 1
Registered: January 2006
Junior Member
Hi
I am using SQL Loader to insert records from flat file onto a table. But, some of the records in my flat file are duplicates and I need to insert only the firstly encoutered one. The records in the flat file are sorted. Is there any I can insert only the frst row enountered?

Thanks,
Janaki Ram
Re: Eliminating duplicate rows while using SQL loader [message #157045 is a reply to message #157041] Tue, 31 January 2006 00:38 Go to previous messageGo to next message
nkripakaran
Messages: 2
Registered: March 2005
Location: india
Junior Member

hai ,
i want to call the sql loader from my forms is it possible.

do reply
Re: Eliminating duplicate rows while using SQL loader [message #157050 is a reply to message #157041] Tue, 31 January 2006 01:25 Go to previous messageGo to next message
pattik
Messages: 1
Registered: January 2006
Location: S.E.QLD Australia
Junior Member
Refer
restrict duplicate data through sql*loader [message #144909]

Essentially a) use unique constraint and let sqlldr reject records, danger being that you need to check to ensure no other records are also rejected
or

b) load into stage table, and use sql to insert unique records to main tables. I always try to use this approach unless doing a quick and dirty load. For production loads, I usually make the stage tables all varchar2(4000) or similar so nothing fails unless the data is really corrupt and then do validation in subsequent load. This way, errors can be generated to a stage error table and reported nicely to users simplying the data.

Regards

Re: Eliminating duplicate rows while using SQL loader [message #157051 is a reply to message #157045] Tue, 31 January 2006 01:25 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
No there is no way.

You could create a unique index on the columns, then the duplicates will just fail. Note that every duplicate will write a line to the log, as well as to the BAD file, so it is not really "silent". This won't work for direct-path loads.

You could also use an Externally Organized Table (Google it), and then eliminate duplicates with a SQL statement as you insert into the target table.

_____________
Ross Leishman
Re: Eliminating duplicate rows while using SQL loader [message #157074 is a reply to message #157051] Tue, 31 January 2006 04:15 Go to previous message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
As stated above by others,
There is no direct way.
A unique constraint/index will do the job.
or
You can use a staging table or an exception table as show here
http://www.orafaq.com/forum/m/70632/42800/#msg_70632
Previous Topic: ordering rows in a table
Next Topic: BULK INSERT in PL/SQL
Goto Forum:
  


Current Time: Thu Aug 21 14:17:18 CDT 2025