问题一: create trigger a_tir before insert on a for each row begin update b set other3=:new.other3,other4=:new.other4,other5=:new.other5,other6=:new.other6 where code=:new.code; end; /
问题二: insert into b (code,revnumber,other1) select code,revnumber,other1 from a where not exists(select 1 from b where a.code=b.code)
问题一:建议直接修改应用程序问题二:insert into b (code,revnumber,other1) select code,revnumber,other1 from a where code not in (select code from b)
问题1:1:) 直接修改程序2:) 根本不要在程序中写insert into b,而直接在a表上建立触发器,create trigger a_tir after insert on a for each row begin insert into b (code,name,other1,other2,other3,other4,other51,other6) values (:new.code,:new.name,:new.other1,:new.other2,:new.other3,:new.other4,:new.other5,:new.other6) end;这样还可以避免你程序中错误问题2:以上几位说得太清楚了
create trigger a_tir
before insert on a
for each row
begin
update b set other3=:new.other3,other4=:new.other4,other5=:new.other5,other6=:new.other6 where code=:new.code;
end;
/
insert into b (code,revnumber,other1) select code,revnumber,other1 from a where not exists(select 1 from b where a.code=b.code)
第一个问题可能是我没有说清楚吧,简单的说,就是程序中没有将other3到other6的数据写到表b,所以想通过触发器来实现(数据来自表a),其实这个问题很BT的^_^
各人意见!
after insert on a
for each row
begin
insert into b
(code,name,other1,other2,other3,other4,other51,other6)
values (:new.code,:new.name,:new.other1,:new.other2,:new.other3,:new.other4,:new.other5,:new.other6)
end;这样还可以避免你程序中错误问题2:以上几位说得太清楚了