日期:2014-05-16  浏览次数:20871 次

关于oracle中的PL/SQL模糊查询的问题
有表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表中存在的字段,且不知道前面有几位相同,求教



------解决方案--------------------
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;
/