Re: Copying data with triggers
| От | Tom Lane |
|---|---|
| Тема | Re: Copying data with triggers |
| Дата | |
| Msg-id | 27970.966900076@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Copying data with triggers (Keith Wong <keith@e-magine.com.au>) |
| Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: