Re: Copying data with triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Keith Wong <keith(at)e-magine(dot)com(dot)au>
Cc: pgSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Copying data with triggers
Date: 2000-08-21 23:21:16
Message-ID: 27970.966900076@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Keith Wong <keith(at)e-magine(dot)com(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Tille 2000-08-22 07:39:18 Re: Beginner problems with functions
Previous Message jason watkins 2000-08-21 23:20:48 copy DELETES to audit table