本帖最后由 whiteprincer 于 2011-03-23 20:36:08 编辑

解决方案 »

  1.   

    把before改成after 会报错,但before时,根本没有数据插入表M
      

  2.   

    没有数据插入M表,可能是条件不满足吧
    你可以一个一个排查 看看哪个if没有走
    if inserting then
           open c1;
           fetch c1 into cur_c1;
    --该处用dbms_output.put_line把cur_c1.name输出,看看值是什么
               if cur_c1.name='UUU' then
                 open c2;
                 loop
                    fetch c2 into cur_c2;
    --该处输出c2查出了多少行 如果没有数据 直接就exit了 当然不往M表写记录
                     exit when c2%notfound;
                      insert into  M  values( sysdate,:new.id, cur_c2.id)   ;
                 end loop;
                 close c2;
               -- else ...暂不实行;
                end if;
             close c1;
    end if;
      

  3.   


    --trigger里用cursor,这样的用法确定没错就行,数据我保证能够查询出来。能确认用法做是没有错的吗?
      

  4.   

    if cur_c1.name='UUU' then--把这句去掉之后,就可以插入数据,看来是if 条件不成立,
    --但是,cursor c1中我取出来的值确实是‘UUU’,为什么if条件不成立?
      

  5.   

    cur_c1 c1%rowtype;
    cur_c2 c2%rowtype;
    不知道你为什么这么定义
    感觉定义成varchar2完全可以啊
    fetch c1.name into cur_c1;
               if cur_c1='UUU' then
                 open c2;