Re: Updating another table using a trigger

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Robert Fitzpatrick <robert(at)webtent(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Updating another table using a trigger
Date: 2004-09-15 15:18:47
Message-ID: 20040915081551.L58656@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, 15 Sep 2004, Robert Fitzpatrick wrote:

> I am running PostgreSQL 7.4.5 and have a trigger on a table called
> tblriskassessors which inserts, updates or delete a corresponding record
> in tblinspectors by lookup of a contact id and license number match. The
> INSERT and DELETE work fine. The UPDATE works good unless I update the
> license number. The error, at the bottom of this message, suggests the
> primary key violation. But my UPDATE in no way alters the primary key,
> which is inspector_contact_id. A manual update on tblinspectors using
> the same values works fine. There is a foreign key on tblriskassessors
> assessor_contact_id field to the primary key above. The structures of
> the two tables can be found below as well.

Are you sure that you're going in the update path and not the insert path
inside the function? Could the select/if not found be taking effect at
which point the insert occurs rather than the else block?
RAISE NOTICE might be useful to determine thise.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2004-09-15 15:24:09 Re: Spacing in output
Previous Message Robert Fitzpatrick 2004-09-15 15:02:21 Updating another table using a trigger