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

Re: Delete / F/K error

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Delete / F/K error
Date: 2005-12-30 22:01:40
Message-ID: 20051230220140.GA1684@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-general
On Fri, Dec 30, 2005 at 12:09:12PM -0800, CSN wrote:
> ERROR:  insert or update on table "types" violates
> foreign key constraint "$1"
> DETAIL:  Key (page_template_id)=(8) is not present in
> table "templates".
> CONTEXT:  SQL statement "UPDATE ONLY "public"."types"
> SET "item_template_id" = NULL WHERE "item_template_id"
> = $1"
> SQL statement "DELETE FROM ONLY "public"."templates"
> WHERE "site_id" = $1"
> 
> In statement:
> DELETE FROM "sites" WHERE "id"='1'

What are the table definitions for sites, templates, and types?
I'd guess you have some ON DELETE CASCADE and ON DELETE SET NULL
foreign key constraints in templates and types.  Think through what
happens when those constraints are triggered by the delete on sites;
somehow you're ending up with a foreign key that violates its
constraint so the delete fails.

What version of PostgreSQL is this?

-- 
Michael Fuhr

In response to

Responses

pgsql-general by date

Next:From: Jim ButtafuocoDate: 2005-12-30 22:02:48
Subject: Re: unique constraint with a null column?
Previous:From: Ubence QuevedoDate: 2005-12-30 21:53:55
Subject: Correct way to set up Variables [Was - Simple Accumulating Number Loop?]

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