Re: Trigger Update Issue - Mailing list pgsql-general

From beer
Subject Re: Trigger Update Issue
Date
Msg-id 42511.192.88.209.232.1078499187.squirrel@webmail.andrew.cmu.edu
Whole thread Raw
In response to Re: Trigger Update Issue  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Richard

Thanks for the suggestion.  I had tried something similar using FOUND but
that didnt not give me the number of rows touched.

According to the output, 1 row was updated, however when I select on the
row the value is still 0.

-b

> 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: "Rod K"
Date:
Subject: Re: REFERENCES error message complaint, suggestion
Next
From: Bruce Momjian
Date:
Subject: Re: REFERENCES error message complaint, suggestion