Re: Trigger Update Issue

From: Richard Huxton <dev(at)archonet(dot)com>
To: "beer" <beer(at)cmu(dot)edu>, pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger Update Issue
Date: 2004-03-05 14:45:18
Message-ID: 200403051445.18318.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2004-03-05 14:56:01 Re: REFERENCES error message complaint, suggestion
Previous Message David Garamond 2004-03-05 14:35:30 Re: relocatable binary distribution