pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Keith Wong <keith@e-magine.com.au>
Cc: pgSQL <pgsql-sql@postgresql.org>
Subject: Re: Copying data with triggers
Date: Mon, 21 Aug 2000 19:21:16 -0400
Message-ID: <27970.966900076@sss.pgh.pa.us> (raw)
In-Reply-To: <4.3.2.7.0.20000822003607.00b0d6b0@mail.e-magine.com.au>
References: <002f01c00af3$4efce0a0$0b01a8c0@ivsol>
	<4.3.2.7.0.20000822003607.00b0d6b0@mail.e-magine.com.au>

Keith Wong <keith@e-magine.com.au> writes:
> create function tp_info () returns opaque as '
> 	begin
> 		-- insert into audit table
> 		insert into AudInfo (info_id, some_data, aud_operation_type) values 
> (new.info_id, new.some_data, ''i'');
> 		return new;
> 	end;
> ' language 'plpgsql';

> create trigger tp_info before insert on Info
> 	for each row execute procedure tp_info();

> This doesn't work however. A parse error occurs in the first line.
> I suspect that I cannot insert a record into another table in a trigger. 

You certainly can --- I have apps that do it all the time.  I suspect
maybe the plpgsql parser gets confused by SQL-style comments?  Your
example seems to work fine if I leave out the comment.

			regards, tom lane



view thread (2+ messages)

Message-ID: <27970.966900076@sss.pgh.pa.us>
Permalink:  ../27970.966900076@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27970.966900076@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, keith@e-magine.com.au
  Subject: Re: Copying data with triggers
  In-Reply-To: <27970.966900076@sss.pgh.pa.us>
  References: <002f01c00af3$4efce0a0$0b01a8c0@ivsol> <4.3.2.7.0.20000822003607.00b0d6b0@mail.e-magine.com.au> <27970.966900076@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