Skip site navigation (1) Skip section navigation (2)

Re: Problem with some keys

From: Peter Headland <Peter(at)matrixlink(dot)com>
To: cipy(dot)mail(at)gmail(dot)com
Cc: sfpug(at)postgresql(dot)org
Subject: Re: Problem with some keys
Date: 2012-03-18 00:05:20
Message-ID: 4F6526C0.8000605@matrixlink.com (view raw or flat)
Thread:
Lists: sfpug
The "ON UPDATE SET DEFAULT" clause in the FK definition tells Postgres 
to change the value of mostra.museo to the default value of 
museo.nomemuseo, which is 'MuseoVeronese'. In other words, it is as if 
you had executed this:

UPDATE mostra SET museo = 'MuseoVeronese';

If you execute the statement above, you will see the same error. The 
error is telling you that there is no row in the museo table with a 
nomemuseo value of 'MuseoVeronese', so the FK relationship from mostra 
to museo is violated. Looking at your INSERT statements, I see that you 
never created a row for that museum; if you insert a row for 
'MuseoVeronese' in museo, your problem will go away.

-- 
Peter Headland


In response to

Responses

sfpug by date

Next:From: cipy.mailDate: 2012-03-18 14:38:16
Subject: Re: Problem with some keys
Previous:From: Peter HeadlandDate: 2012-03-17 21:36:35
Subject: Re: Problem with some keys

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group