Reputation: 11
I am creating a control table in a PostgreSQL database, this table should register the query that fired a trigger in a specific table. For instance
if I do
insert into employees('bob');
I would like to be able to capture the string 'insert into employees('bob');' inside a trigger associated with employees table. It doesn't matter if the trigger is before or after.
Upvotes: 1
Views: 1115
Reputation: 121544
Use the function current_query()
in the trigger function.
insert into control_table(query_text)
select current_query();
The trigger should be for each statement
.
Upvotes: 2