Re: Problem with some keys

From: cipy(dot)mail(at)gmail(dot)com
To: Peter Headland <Peter(at)matrixlink(dot)com>
Cc: sfpug(at)postgresql(dot)org
Subject: Re: Problem with some keys
Date: 2012-03-18 14:38:16
Message-ID: CAJaL4WZrEhhRvbKuD5jQQXp0F4mgNRf=OOwjVsU3t11cxVMtCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug

Thanks for the reply Peter, but

the row with 'MuseoVeronese' and 'Verona' in the table museo exists i've
created it with the first INSERT:

insert into museo (indirizzo,giornochiusura,prezzoridotto) values('Via
Centro','Mercoledì',5.0);

it takes the default values of table museo, 'MuseoVeronese' and 'Verona'.

S. Ciprian

2012/3/18 Peter Headland <Peter(at)matrixlink(dot)com>

> 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
>
>

--
"La vita è piacevole. La morte è pacifica. E' la transizione che crea dei
problemi." cit. Isaac Asimov

In response to

Responses

Browse sfpug by date

  From Date Subject
Next Message Peter Headland 2012-03-18 16:05:56 Re: Problem with some keys
Previous Message Peter Headland 2012-03-18 00:05:20 Re: Problem with some keys