pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stefan Sylla <stefansylla@gmx.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: update column based on postgis query on anther table
Date: Tue, 16 Jul 2013 01:24:33 -0400
Message-ID: <317.1373952273@sss.pgh.pa.us> (raw)
In-Reply-To: <51E4B5A5.4040805@gmx.de>
References: <51E4B5A5.4040805@gmx.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


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



view thread (5+ messages)  latest in thread

Message-ID: <317.1373952273@sss.pgh.pa.us>
Permalink:  ../317.1373952273@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/317.1373952273@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, stefansylla@gmx.de
  Subject: Re: update column based on postgis query on anther table
  In-Reply-To: <317.1373952273@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox