Re: REFERENCES error message complaint, suggestion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: REFERENCES error message complaint, suggestion
Date: 2004-03-04 03:37:48
Message-ID: 20851.1078371468@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Karl O. Pinc" <kop(at)meme(dot)com> writes:
> It'd be nice if the error message from a REFERENCES
> constraint mentioned the column name into which
> the bad data was attempted to be inserted.

You mean like this?

regression=# create table foo (pk int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
CREATE TABLE
regression=# create table bar (fk int references foo);
CREATE TABLE
regression=# insert into bar values(1);
ERROR: insert or update on table "bar" violates foreign key constraint "$1"
DETAIL: Key (fk)=(1) is not present in table "foo".
regression=# select version();
version
---------------------------------------------------------------
PostgreSQL 7.4.1 on hppa-hp-hpux10.20, compiled by GCC 2.95.3
(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message scrappy 2004-03-04 04:00:04 :)
Previous Message JustSomeGuy 2004-03-04 02:18:30 need advice.