CREATE OR REPLACE TRIGGER Test
AFTER INSERT ON t1 FOR EACH ROW
BEGIN
  insert into t2 (id,t2c1,t2c2)
      select t1.id,t1.t1c1,t3.t3c1 from t1,t3
          where t1.id=t3.id and t1.id = :New.id;
END;

解决方案 »

  1.   

    补充:
    CREATE OR REPLACE TRIGGER Test
    AFTER INSERT ON t1 FOR EACH ROW
    BEGIN
      insert into t2 (id,t2c1,t2c2)
          select t1.id,t1.t1c1,t3.t3c1 from t1,t3
              where t1.id=t3.id and t1.id = :New.id AND 
                    (t1.t1c1 IS NOT NULL AND T3.t3c1 IS NOT NULL);
    END;
      

  2.   

    create or replace trigger aft_ont1
    after insert on t1
    for each row
    begin
    insert into t2(id,t2cl,t2c2)
      select t1.id,t1.t1cl,t3.t3cl from t1,t3
        where t1.id=:new.id and t1.id=t3.id and t1.t1cl is not null and t3.t3cl is not null
    end;
    /
      

  3.   

    create trigger a_tri
    before insert on a
    for each row
    declare
    str varchar2(50);
    begin
    select t3c1 into str from t3 where id=:new.id;
    if :new.t1c1 is not null and str is not null then
    insert into t2 select :new.id,:new.t1c1,t3c1 from t3 where id=:new.id;
    end if;
    end;
    /
      

  4.   

    前两位朋友的在插入数据时出错:“表1发生了变化,触发器/函数不能读。”这是为什么?
    天星的有编译错误,
    最后一个把表名变为t1 就对了,谢谢大家还顺便问:DBA  Studio中日期字段的显示格式是不能改变的。是真的吗?