如何访问新值Statement Level Trigger [英] How to access new value Statement Level Trigger

查看:112
本文介绍了如何访问新值Statement Level Trigger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我希望在语句级别触发器中更新后访问新值。

但在我的查询中我得到了旧值。

这是触发代码:


创建或替换TRIGGER TEST_TRIGGER

更新table_gyan上的col3后

DECLARE

PRAGMA AUTONOMOUS_TRANSACTION;

v_count NUMBER:= 0;

v_temp_count NUMBER:= 0;

BEGIN

SELECT计数(1)从table_gyan进入v_count,其中col3 =''Y'';

如果v_count> 0那么

SELECT COUNT(1)INTO v_temp_count来自TRIGGER_TABLE;

如果v_temp_count> 0那么

更新TRIGGER_TABLE设置行动=''开始'';

COMMIT;

else

插入TRIGGER_TABLE(ACTION)值(''START'');

commit;

end if;

结束IF;

结束;






现在什么时候我执行这个查询

更新table_gyan设置col3 =''Y''

其中col1 =''3''

和col2 =''100 ''

它没有用TRIGGER_TABLE做任何事情。



请帮我怎么做。


问候,

Gyanendar

解决方案

您确定有任何记录更新吗?


Pilgrim。



你确定有任何记录更新吗?


Pilgrim。



在表中记录正在更新但触发器仍然是旧值。


Ok,


所以现在你在表格中有值,其中col3的值为''Y''现在尝试更新col3,看看是否更新了trigger_table。


路历程。

Hi All,
I want to access new value after upadate in statement level trigger.
But in my query I am getting old values.
Here is the Trigger Code:

CREATE OR REPLACE TRIGGER TEST_TRIGGER
AFTER UPDATE OF col3 on table_gyan
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
v_count NUMBER:=0;
v_temp_count NUMBER:=0;
BEGIN
SELECT Count(1) into v_count from table_gyan where col3=''Y'';
If v_count>0 THEN
SELECT COUNT(1) INTO v_temp_count from TRIGGER_TABLE;
if v_temp_count>0 THEN
UPDATE TRIGGER_TABLE SET ACTION=''START'';
COMMIT;
else
insert into TRIGGER_TABLE(ACTION) values(''START'');
commit;
end if;
END IF;
END;

.


Now when ever I am executing this query
update table_gyan set col3=''Y''
where col1=''3''
and col2=''100''
Its not doing anything with TRIGGER_TABLE.


Please help me how to do it.

Regards,
Gyanendar

解决方案

Are you sure any records are updated?

Pilgrim.


Are you sure any records are updated?

Pilgrim.

In the table records are getting updated but trigger is still taking Old value.


Ok,

So now you have values in the table where col3 has the value ''Y'' Try to update col3 now, and see if the trigger_table is updated.

Pilgrim.


这篇关于如何访问新值Statement Level Trigger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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