Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL*Loader

Posted on 2003-11-04
5
Medium Priority
?
570 Views
Last Modified: 2013-12-12
I have certain constraints on the DB. When I load a file using SQL*Loader, however, the constraints are violated. Why does this happen? Is there any way to ignore the violating records, and complete loading?
0
Comment
Question by:archan_dhar
5 Comments
 
LVL 8

Accepted Solution

by:
Danielzt earned 252 total points
ID: 9679362
try to do this way base on your requirements.

1: if you care about data more than constraints, you can diable the constraints and then load.

2: you can use these two options to control  the number of error or discards.

discardmax              Number of discards to allow
errors          Number of errors to allow

3: change your data to meet your constraints.

0
 

Author Comment

by:archan_dhar
ID: 9679596
Thanks for your comments. I have already successfully tried out case 3, but ideally, I wont like that method.

Regarding case 2, I just want to discard the cases that violates the unique key constraint on one column. No specific number of discards can be pin pointed.

To be very clear with my requirement, let me give an example. Following is the data file:

AA,PPPPP,1
BB,QQQQ,2
BB,FFFFF,3
CC,GGGG,4
CC,KKKK,5
DD,LLLL,6

The column in the table that is assigned for the first column in the data file is the primary key.
My problem is when I upload the above file into DB using SQL*Loader, all the columns get loaded. This violates the unique key constraint on the primary key. I just want the following rows to be loaded:

AA,PPPPP,1
BB,QQQQ,2
CC,GGGG,4
DD,LLLL,6
0
 
LVL 3

Assisted Solution

by:ubasche
ubasche earned 248 total points
ID: 9702227

You must set the number of discards to allow to a high enough number.
It will work, if you set it higher than the number of duplicates you will get it the file you are loading.

E.g. If you have 400 duplicates and you set the number of discards to 1000,
you will get 400 discards and the load will complete (because you still have 600 discards left before SQL*Loader aborts the load).

0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 10200320
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between Danielzt and ubashe.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Henka
EE Cleanup Volunteer
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question