Foreign Key Problem

From: Dennis Muhlestein <dennis(at)zserve(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Foreign Key Problem
Date: 2001-06-07 21:39:44
Message-ID: 9fosb1$148o$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is This s bug:

create table A
(
key varchar(20) not null primary key
);

create table B
(
id serial not null primary key,
col1 varchar(20) not null,
col2 varchar(20) not null
);

alter table B create constraint fk_col1 foreign key ( col1 ) references A (
key ) on delete cascade on update cascade;

alter table B create constraint fk_col2 foreign key ( col2 ) references A (
key ) on delete cascade on update cascade;

SQL Creation and operation works fine. In the case that one row in table B
where col1 = col2, if I update A.key, I'll get a referential integrity
violation??

ie: ERROR: fk_col1 referential integrity violation - key referenced from B
not found in A.

Is there a way to make this type of constraint work with the update?

If not, is there a way to create a constraint so that col1 != col2 is
inforced?

Thanks in advance..
Dennis

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arcady Genkin 2001-06-07 22:02:53 REPOST: redefining location of the socket file /tmp/.s.PGSQL.5432
Previous Message Somazx Interesting 2001-06-07 19:56:28 pg_dumpall error