I want to avoid all the records to be inserted into a table using SQL Loader. The table in which we are inserting has a primary key over 3 columns. Whenever duplicate occurred, code gets failed with a primary key violation.
I have a requirement to skip/avoid all the record having more than one occurrence in the data file while inserting using control file. Could anyone please help me out here?
Is there any way to skip those records by adding some conditions in control file itself?
To me, it seems that you're looking for a problem, while there's no problem at all.
.logfile.badfileJust in case you didn't know, there's the
errorsparameter; its value is integer, and it shows how many errors you want to allow:So, what is the problem? I don't see any.
As it seems that - in case of duplicates - you don't want to load any of those rows as you don't know which one is correct, I don't think that SQL Loader is capable of doing that.
One option is to switch to external table which has the input file as a source and acts as an "ordinary" table and lets you write
SELECTstatements directly, without previously loading data into the database. It enables you to skip duplicates, e.g.Or, you could disable primary key constraint, load data as you do it now (including duplicates), and then delete all duplicates, e.g.
Then re-enable the primary key constraint.