Re: Can a table have a reference to itself?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Duke-Williams <o(dot)duke-williams(at)geog(dot)leeds(dot)ac(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Can a table have a reference to itself?
Date: 2003-07-28 05:31:29
Message-ID: 27090.1059370289@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oliver Duke-Williams <o(dot)duke-williams(at)geog(dot)leeds(dot)ac(dot)uk> writes:
> So far so good, but what I'd like to do is to be able to change a value
> of a, and have this cascaded to b; however this gives an integrity
> violation error:

>> update foo set a = 5 where a = 2;
> ERROR: chk_a referential integrity violation - key referenced from foo
> not found in foo

Seems to work in 7.3.4 and CVS tip:

regression=# update foo set a = 5 where a = 2;
UPDATE 1
regression=# select * from foo;
a | b
---+---
1 | 1
3 | 5
5 | 5
(3 rows)

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-07-28 05:45:54 Re: Using a compound primary key
Previous Message Toby Tremayne 2003-07-28 04:12:35 join optimization problem