Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e7LNLNT02091 for ; Mon, 21 Aug 2000 19:21:23 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id TAA27973; Mon, 21 Aug 2000 19:21:16 -0400 (EDT) To: Keith Wong cc: pgSQL Subject: Re: Copying data with triggers 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> Comments: In-reply-to Keith Wong message dated "Tue, 22 Aug 2000 00:48:27 +1000" Date: Mon, 21 Aug 2000 19:21:16 -0400 Message-ID: <27970.966900076@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200008/214 Keith Wong 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