"Keith Worthington" <keithw@narrowpathinc.com> writes:
> 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?
Use a more recent version of Postgres?
In 7.4 I get something like
regression=# alter table bar add foreign key (f1) references foo;
ERROR: insert or update on table "bar" violates foreign key constraint "$1"
DETAIL: Key (f1)=(2) is not present in table "foo".
regards, tom lane