Re: Trigger Update Issue

From: "beer" <beer(at)cmu(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger Update Issue
Date: 2004-03-05 15:06:27
Message-ID: 42511.192.88.209.232.1078499187.squirrel@webmail.andrew.cmu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-03-05 15:12:27 Re: REFERENCES error message complaint, suggestion
Previous Message Tom Lane 2004-03-05 15:01:08 Re: sum of a time column