Copy/foreign key contraints

From: "Ken Godee" <ken(at)perfect-image(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Copy/foreign key contraints
Date: 2002-12-13 15:14:11
Message-ID: 3DF996D2.759.314A8B@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Being fairly new to postgres I'm trying to find my way
around this, did some searching and see this has come
up quite a few times, but..........

table 1: customer.custid primary key
table 2: transx.custid foreign key

When using COPY to import data I received;

"<unnamed>referential integerity violation-key referenced from
table transx not found in customer" (fairly vague statement)

I'm sure many know where this is going, but I'll still explain
what I've tried so far.......

Then created a copy/temp table of transx with no constraints
and COPY'ed data into it, ran some "where not exists" statements
against the customer.custid and found no unmatched
primary/foreign keys. Tried to do an INSERT from the temp table
into the transx table and still got the referential integerity violation.
At this point I'm presuming that my data's ok, so now what.....

Drop the foreign key, import data, then add foreign key back?
But what if there is a real "referential integerity violation"?
How are others dealing with this or am I just doing something
wrong?

postgres 7.2.1 / Rh7.3

Also as a side note;
It would be nice while data import if it
would just create an exception file and continue the import
of data with a way to see/count exceptions at the end of import
with a choice to then process the file and save the exceptions.

Sorry to ramble........

Ken

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Beutin 2002-12-13 15:41:38 Re: INDEX suggestion needed
Previous Message Robert Treat 2002-12-13 14:37:55 Re: 'vacation' flag for the list?