这个Channel_id唯一不?这条语句是更新的当前记录么?如果是的话直接对:new.Channel_id赋值就可以了!如果是多条记录或者不是当前记录的话就有困难了!
update BASE_RTU set Channel_id=(select max(Channel_id) from BASE_Channel)
where RTU_Id = :NEW.RTU_ID;
update BASE_RTU set Channel_id=(select max(Channel_id) from BASE_Channel)
where RTU_Id = :NEW.RTU_ID;
关键在BASE_RTU触发器中不能更新、查询自己表的相关值
SQL Statements Allowed in Trigger BodiesThe body of a trigger can contain DML SQL statements. It can also contain SELECT statements, but they must be SELECT... INTO... statements or the SELECT statement in the definition of a cursor.建议:
select max(Channel_id) into 变量 from BASE_Channelupdate BASE_RTU set Channel_id = 变量
where RTU_Id = :NEW.RTU_ID;
触发器中不能修改本表的值,否则不是死循环了
说的是对的,有没有什么好的办法实现更改自己表!