require some suggestion to write trigger function
От | Jignesh Shah |
---|---|
Тема | require some suggestion to write trigger function |
Дата | |
Msg-id | c11950270909070233r642ef8aap4b539cb2319cbf1f@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: require some suggestion to write trigger function
|
Список | pgsql-novice |
Hi, could any one please help me with below situation. Thanks for your time in advance.
I have two tables Foo1(c1,c2,c3) and Foo2(x1,x2,x3). I have written trigger for Foo1 and it is working fine. The trigger updates the log table when new insertion happened in Foo1. For this, I have used below code.
CREATE OR REPLACE FUNCTION my_triggert() RETURNS trigger AS $$$rv = spi_exec_query("insert into logtable VALUES($_TD->{new}{c1}, '$_TD->{new}{c2}','$_TD->{new}{c3}');");($rv->{processed} == 0 && $rv->{status} eq "SPI_OK_INSERT") ?
elog(INFO, "Success") :
elog(INFO, "Failed");$$ LANGUAGE plperl;
I have hard coded the columns name c1, c2, c3. Is it possible to get rid of hard coding c1, c2 and c3 so that I can use same my_trigger function for Foo2(x1, x2, x3) as well? Any suggestion would be really helpful for me.
Thanks,
Jignesh
В списке pgsql-novice по дате отправления: