![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Does a function executed by a trigger know which table fired the trigger? |
#3
| |||
| |||
|
|
Raphael Bauduin <raphael.bauduin (AT) be (DOT) easynet.net> writes: Does a function executed by a trigger know which table fired the trigger? Depends what language you're writing the trigger in, but I believe most of them do. For plpgsql see http://www.postgresql.org/docs/7.4/s...l-trigger.html |
|
regards, tom lane |
#4
| |||
| |||
|
|
Does a function executed by a trigger know which table fired the trigger? |
|
I'm using the same function for several triggers on different tables. Now, I'm passing the table name as argument: CREATE TRIGGER "customers_update_log_t" after UPDATE on "customers" for each row execute procedure "customers_update_log"('customers'); I wondered if in the function code, we have access to the table name that fired the trigger. |
|
Also, does the function have access to the type of action that fired the trigger? Eg, if I create a trigger after update and insert, is it possible to know if it's an insert or an update that fired the trigger? |
#5
| |||
| |||
|
|
On Wed, Aug 11, 2004 at 09:44:42AM +0200, Raphael Bauduin wrote: snip Also, does the function have access to the type of action that fired the trigger? Eg, if I create a trigger after update and insert, is it possible to know if it's an insert or an update that fired the trigger? That would be TG_OP. See the PL/pgSQL "Trigger Procedures" manual page for more info: http://www.postgresql.org/docs/7.4/s...l-trigger.html If you're using a language other than PL/pgSQL then see that language's trigger documentation. I'm trying to use it in a plpgsql trigger. I want to insert a row in a table named |
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |