Re: finding data violating constraint

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: KeithW(at)narrowpathinc(dot)com
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: finding data violating constraint
Date: 2004-10-19 13:44:53
Message-ID: 1098193492.24233.24.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, 2004-10-19 at 14:04, Keith Worthington wrote:
> I am trying to build a foreign key constraint. The objective is to prevent
> parts from being entered that do not have a valid sales account. When I try
> to build the constraint it fails telling me that there is a violation. I have
> looked at the data and just can't seem to find the problem. Is there a way to
> find the data that is causing the problem? I tried deleting all the data and
> building the constraint. That of course works but then I am unable to load
> the data and I have no better idea of where the problem is located.

You need to show the definitions for the tables involved, how you are
inserting your data and the exact text of error messages. Your
description is far too general for us to help you much.

If you add a constraint after the table is created, the existing data
must satisfy the constraint.

If you add the data after the constraint, it clearly must be added in
the correct order; the sales account data would need to be inserted
first. When you load the dependant table's data, PostgreSQL ought to
tell you which data it is objecting to.
--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Commit thy way unto the LORD; trust also in him and
he shall bring it to pass." Psalms 37:5

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2004-10-19 14:44:23 Re: finding data violating constraint
Previous Message Keith Worthington 2004-10-19 13:04:46 finding data violating constraint