是否可以为当前会话禁用Oracle触发器? [英] Can an Oracle trigger be disabled for the current session?

查看:71
本文介绍了是否可以为当前会话禁用Oracle触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在将数据插入表之前禁用表上的特定触发器,但是在不影响其他用户的情况下,该用户可能正在更改同一表中的数据.我找不到任何记录的方式来做到这一点.这是Oracle 11g.

I'd like to disable a specific trigger on a table prior to inserting data into it, but without affecting other users that may be changing data in that same table. I can't find any documented way to do this. This is Oracle 11g.

我能想到的最好的解决方案是创建一个会话变量,并将我的应用程序设置为触发器在执行其工作之前要检查的某个值.

The best solution I've been able to come up with is to create a session variable and have my application set that to some value that the trigger checks for prior to doing its work.

强制性的反触发评论:我讨厌触发器.

推荐答案

将变量添加到现有程序包规范中(或创建新程序包):

Add a variable to an existing package spec (or create a new package):

enable_trigger boolean := true;

将触发器中的代码括起来:

Surround the code in the trigger with:

if enable_trigger then

end if;

当您要禁用"触发器时,请将变量设置为false.

When you want to "disable" the trigger set the variable to false.

最佳实践是将变量放入主体并编写一个设置过程和一个get函数.

A Best Practice would be to put the variable in the body and write a set procedure and a get function.

这篇关于是否可以为当前会话禁用Oracle触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆