我的意思是当A中插入一条新的数据,那么就将这个数据也插入到B中,A跟B的结构完全一致,而且数据项很多,我不想写成: when inserting then insert into B@REP remote value(:new.a1,:new.a2,...); 我打算写 when inserting then insert into B@REP remote select * from A where =新增的那一条 ; 就是不知道这个条件该怎么写,谢谢了
建立after insert触发器,假设A表的主键是id这字段,试一下when inserting then insert into B@REP remote select * from A where id = :new.id;
假设A的主键是数据项a13,我将语句改为 when inserting then insert into B@REP remote select * from A where a.a13 = :new.a13; 或 when inserting then insert into B@REP remote select * from A where a13 = :new.a13; 仍旧报错ORA-04091:表A发生了变化,触发器/函数不能读,ORA-04088:触发器执行过程中出错。 A,B2个表里的字段名都完全一样,麻烦各位达人给看看,谢谢
我用的是oracle数据库,用when inserting then insert into B@REP remote value(:new.a1,:new.a2,...);试验成功了,想用when inserting then insert into B@REP remote select * from A where a13 = :new.a13;做测试,可是就是报错啊ORA-04091:表A发生了变化,触发器/函数不能读,ORA-04088:触发器执行过程中出错。怎么回事咧?我在触发器里做delete就用到了where,很好啊,为什么在insert里就不行了呢。我选择是的事件是insert之后。谢谢各位
select * from A,是将A中的所有字段都取出来,而insert into B values()应该是将各个值对应到相应的字段里,select * from A不能代替values()
select * from A如果带上条件where ,那么取出来的就是一条记录,我记得以前好像看过insert into B select * from A where 是可以的,这里A,B2个表结构完全一样,而且a13是表A的主键,where a13=:new.a13查询出来的记录应该是唯一的,可是为什么报错呢 ORA-04091:表A发生了变化,触发器/函数不能读 ORA-04088:触发器执行过程中出错
insert into B select * from A where ..是可以的,但我的第一感觉就是你select出A的列的顺序和B里列的排列顺序不一致导致因类型不匹配造成的,因为你指定了具体的字段是可以插入的。所以不是其他什么问题,问题应该出在插入的语句上
楼主还是得辛苦些把 ... values(:new.a1,:new.a2,...); 里面的所有字段给添上吧。对于触发器中引用触发器自身表的语句,如 insert into ... select ... from xxx where ...; 中的xxx若是触发器本身表的化,不管其结果返回是否多行,都会当变异表报错 ....
when inserting then
insert into B@REP remote
value(:new.a1,:new.a2,...);
我打算写
when inserting then
insert into B@REP remote
select * from A
where =新增的那一条 ;
就是不知道这个条件该怎么写,谢谢了
when inserting then insert into B@REP remote select * from A where a.a13 = :new.a13;
或
when inserting then insert into B@REP remote select * from A where a13 = :new.a13;
仍旧报错ORA-04091:表A发生了变化,触发器/函数不能读,ORA-04088:触发器执行过程中出错。
A,B2个表里的字段名都完全一样,麻烦各位达人给看看,谢谢
ORA-04091:表A发生了变化,触发器/函数不能读
ORA-04088:触发器执行过程中出错
...
values(:new.a1,:new.a2,...);
里面的所有字段给添上吧。对于触发器中引用触发器自身表的语句,如
insert into ... select ... from xxx where ...;
中的xxx若是触发器本身表的化,不管其结果返回是否多行,都会当变异表报错
....
现在只是想探讨一下更简便的方法而已,谢谢各位了