我有一个触发器,它更新value
从表中调用的列,但是当我执行触发器时,value
列的值没有正确设置,它总是设置为 0。触发器是:
create or replace
TRIGGER trigger2
AFTER INSERT ON TABLE_AUX
FOR EACH ROW
DECLARE
BEGIN
.....
IF V_VALUE > 0 THEN
/* V_VALUE IS GREATER THAN 0. THIS WORKS FINE */
SELECT COUNT(*) "NUM" INTO V_NUM
FROM TABLE1 T1,
WHERE ............;
/* V_NUM ALWAYS CONTAINS THE CORRECT VALUE */
/* THE BUG IS IN THIS UPDATE */
UPDATE TABLE_UPDATE
SET "VALUE" = V_VALUE - V_NUM , FIELD_OK = 'OK' /* ONLY FAILS THE FIRST SET */
WHERE ID= (SELECT MAX(ID)
FROM TABLE_UPDATE TAB
WHERE .....);
END IF;
.....
END;
当我之前调用此触发器时,我有另一个触发器插入到一个名为的临时表TABLE_AUX
上:
create or replace
TRIGGER trigger1
BEFORE INSERT ON TABLE_UPDATE
FOR EACH ROW
DECLARE
....
BEGIN
INSERT INTO TABLE_AUX VALUES(....)
END;
TABLE_UPDATE
与 中使用的表相同trigger2
。变量V_VALUE
和V_NUM
使用的trigger1
是NUMBER
变量,value
列是NUMBER(30,20)