Search Postgresql Archives

Re: Rule Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 25, 2013 at 3:02 PM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
> Luca Ferrari <fluca1978@xxxxxxxxxxx> writes:
>> The original post was related to the update of b, so I guess it is
>> better to limit the trigger scope to update on such column:
>
>> CREATE OR REPLACE FUNCTION b_mirror() RETURNS TRIGGER AS
>>  $mirror$
>>  BEGIN
>>  NEW.a = NEW.b;
>>  RETURN NEW;
>>  END;
>>  $mirror$ LANGUAGE plpgsql;
>
>> CREATE TRIGGER tr_b_mirror AFTER UPDATE OF b ON cats FOR EACH ROW
>> EXECUTE PROCEDURE b_mirror();
>
>> It is worth noting that the trigger could be an after one,
>
> No, it has to be a BEFORE trigger, else it's too late to affect the
> row value that gets stored.

Ops..I wrote it without my brain with me: of course it has to be a before one.

Thanks,
Luca


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux