Get the string of the query that fired a trigger
问题 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. 回答1: Use the function current_query() in the trigger function. insert into control_table(query_text) select current_query(); The