可以这样写,但是你的最后一句最好改为:end my_tr;

解决方案 »

  1.   

    行是行,不过table2表中应该只有一条记录,否则会出错
      

  2.   

    主要处理没有错误,不过select table2.字段1 into myvar from table2这一句有点问题,
    应该加点条件确保只返回一行结果
      

  3.   

    那你还不结束帖子?呵呵大家的成果哦~~
    create or replace trigger my_tr
    before insert on table1 for each row
    declare
      myvar number;
    begin
      select table2.字段1 into myvar from table2;
      :new.字段3 := myvar;    (这里是这样写吗?)
    end;
    这样就可以了。。如果出现结果集的话最好加上索引查询或者改用其他办法取值
      

  4.   

    create or replace trigger my_tr
    before insert on table1 for each row
    begin
      select 字段1 into :new.字段3 from table2 where ...;
    end;