获取触发触发器的查询的字符串 [英] Get the string of the query that fired a trigger
本文介绍了获取触发触发器的查询的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在PostgreSQL数据库中创建一个控制表,该表应在特定表中注册触发触发器的查询.例如
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
如果我愿意
insert into employees('bob');
我希望能够捕获字符串插入到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.
推荐答案
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
.
这篇关于获取触发触发器的查询的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文