有表A
port command表B
port    command
12345    FG4
12343    FG6
12345    G表C现插入表C中的记录
insert into C (command) values ('FG47')表A中要出现
port   command
12345   FG47也就是说,插入的字段大于B表中存在的字段,且不知道前面有几位相同,求教

解决方案 »

  1.   

    create or replace trigger trigger_A
    AFTER insert on C
    referencing old as old new as new
    for each row
    declare
      vs_port varchar2(10) ;
    begin
     select port into vs_port from B where regexp_like(:new.command, B.command) and rownum = 1;
     insert into A values (vs_port, :new.command);
    end;
    /
      

  2.   

    ls 真强,居然看懂 lz 的问题了,我都不知道他要干嘛
      

  3.   

    感谢回复,分数不多,就全给了二楼的高人了,因为我用的是oracle9i,还不支持那种正则写法,后来我改了一下
    select port into vs_port from B where :NEW.mocentent like B.command ||'%' and rownum = 1;这样也是可以的