Re: update column based on postgis query on anther table - Mailing list pgsql-sql

From Tom Lane
Subject Re: update column based on postgis query on anther table
Date
Msg-id 317.1373952273@sss.pgh.pa.us
Whole thread Raw
In response to update column based on postgis query on anther table  (Stefan Sylla <stefansylla@gmx.de>)
Responses Re: update column based on postgis query on anther table
Re: update column based on postgis query on anther table
List pgsql-sql
Stefan Sylla <stefansylla@gmx.de> writes:
> Now I want to use a trigger function to automatically update the column 
> 'id_test1_poly' in tabel 'test1_point':

> /**/
> create or replace function test1_point_get_id_test1_poly() returns 
> trigger as $$
>      begin
>          new.id_test1_poly=test1_point_get_id_test1_poly(new.id);
>      return new;
>      end;
> $$
> language plpgsql volatile;
> -- create trigger for function:
> create trigger test1_point_get_id_test1_poly
>    after insert or update on test1_point for each row execute procedure 
> test1_point_get_id_test1_poly();

I think you need that to be a BEFORE insert or update trigger.  In
an AFTER trigger, it's too late to affect the stored row.
        regards, tom lane



pgsql-sql by date:

Previous
From: Stefan Sylla
Date:
Subject: update column based on postgis query on anther table
Next
From: ssylla
Date:
Subject: Re: update column based on postgis query on anther table