Re: Trigger Update Issue - Mailing list pgsql-general

From Richard Huxton
Subject Re: Trigger Update Issue
Date
Msg-id 200403051445.18318.dev@archonet.com
Whole thread Raw
In response to Trigger Update Issue  ("beer" <beer@cmu.edu>)
Responses Re: Trigger Update Issue
List pgsql-general
On Friday 05 March 2004 14:00, beer wrote:
> Hello All
>
> I'm running 7.3.4-1 on a RH9 box.  I'm having a problem with a trigger
> that seems to execute without actually performing the update that it
> should.  The update returns true everytime however if it is the first time
> that the trigger executes on a given row, the column is not updated.  The
> column is updated correctly on subsequent calls.

Perhaps put some debug code in and insert into tabB manually

> CREATE OR REPLACE FUNCTION "tabB_postinsert" () RETURNS TRIGGER AS '
>   --
>   -- Actions to take after inserting into tabB
>   --
DECLARE
  numrows int4;

>   BEGIN
>     -- Increment tabA.attachments
>     UPDATE tabA SET Acol3 = Acol3 + 1 WHERE id = NEW.tabA_id;
  GET DIAGNOSTICTS numrows = ROW_COUNT;
  RAISE NOTICE ''Updated % rows with id = %'',numrows, NEW.tabA_id;
>     -- done
>     RETURN NEW;
>   END; ' LANGUAGE 'plpgsql';

Insert into tabB from psql and you should see a NOTICE message telling you
what is happening.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: phil campaigne
Date:
Subject: Setting up Postgresql on Linux
Next
From: Tom Lane
Date:
Subject: Re: sum of a time column