简体   繁体   English

PostgreSQL - 触发每个语句 - 如何获取查询语句

[英]PostgreSQL - Trigger Each Statement - How to get Query statement

I'm doing a trigger Each Statement and I would like to access the Query Statement that triggered the trigger.我正在执行每个语句的触发器,我想访问触发触发器的查询语句。 Is this possible?这可能吗?

Something like this:是这样的:

update table_1 where id> 300;

This query triggers an update event in table table_1 and this event triggers a function associated with the update trigger.此查询触发表 table_1 中的更新事件,此事件触发与更新触发器关联的 function。 This trigger is configured as Each Statement and inside the trigger I would like to do something like this:此触发器配置为 Each Statement 并且在触发器内部我想做这样的事情:

raise info 'Query Statement that fired this trigger:%', last_query();

Would this be possible?这可能吗?

Thank you!谢谢!

Julio胡里奥

Call the function current_query() .调用 function current_query()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM