有两张表A 和 B 两张的结构相同。现在我又个程序向A中批量插入多条数据,我需要做个触发器达到当程序向A中插入的数据时,同时在B中生成符合条件的数据。应为我向A中插入的数据有可能某些字段为空,或者某些字段不符合条件。我只要符合条件的数据触发到B中。该触发器要怎么写。。如 A(STR1,STR2,STR3,STR4,STR5,STR6,STR7) 所有字段均可为空。
B(STR1,STR2,STR3,STR4,STR5,STR6)其中STR1为主键不可为空,STR3不可为空。要求插入A中的数据,如果STR1不为空,且STR3不为空,且STR7 为‘Y’的数据插入到B表中。该出发器要怎么写呢急需。谢谢有心人帮帮忙。。
B(STR1,STR2,STR3,STR4,STR5,STR6)其中STR1为主键不可为空,STR3不可为空。要求插入A中的数据,如果STR1不为空,且STR3不为空,且STR7 为‘Y’的数据插入到B表中。该出发器要怎么写呢急需。谢谢有心人帮帮忙。。
after INSERT on A
for each row
begin
if :new.STR1 is not null and :new.STR3 is not null and :new.STR7=='Y' then
insert into B(STR1,STR2,STR3,STR4,STR5,STR6)
values(:new.STR1,:new.STR2,:new.STR3,:new.STR4,:new.STR5,:new.STR6);
end if;
end tr_delete;
after INSERT on A
for each row
begin
if :new.STR1 is not null and :new.STR3 is not null and :new.STR7=='Y' then
insert into B(STR1,STR2,STR3,STR4,STR5,STR6)
values(:new.STR1,:new.STR2,:new.STR3,:new.STR4,:new.STR5,:new.STR6);
end if;
end tr_insertB;