Thread: Determining caller of a function (due to a cascaded FK constraint?)
Greetings,
For reasons a little too complicated to get into off the bat, I am wondering what the most effective way is to determine by whom or how a particular action or function call was initiated. To shed more light, I want to have a trigger that will copy some data from a table in one schema to an analogous table in another schema every time a record is modified UNLESS the modification is the result of a cascaded foreign key constraint. My hunch is that the answer somehow includes using data in pg_class and/or pg_proc, but I haven't quite pieced it all together. Does anyone have any recommendations on how to go about this?
Thanks,
JL
"Lenorovitz, Joel" <Joel.Lenorovitz@usap.gov> writes: > I want to have a trigger that will copy some data from a table in one > schema to an analogous table in another schema every time a record is > modified UNLESS the modification is the result of a cascaded foreign key > constraint. Sorry, there isn't any reasonable way for a trigger to tell that. regards, tom lane
On Mon, 09 Oct 2006 16:34:09 -0400 Tom Lane <tgl@sss.pgh.pa.us> wrote: > "Lenorovitz, Joel" <Joel.Lenorovitz@usap.gov> writes: > > I want to have a trigger that will copy some data from a table in > > one schema to an analogous table in another schema every time a > > record is modified UNLESS the modification is the result of a > > cascaded foreign key constraint. > > Sorry, there isn't any reasonable way for a trigger to tell that. thx. I was wondering if *I* wasn't able to find one. I had the same need around a month ago I ended up in adding metadata to tables and "simulating" triggers with a dynamicallygenerated sp. So I could define "deferred" referential integrity nearby table definitions as I was used with pk/fk triggers. -- Ivan Sergio Borgonovo http://www.webthatworks.it