首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

关于oracle中的PL/SQL模糊查询的有关问题

2012-02-09 
关于oracle中的PL/SQL模糊查询的问题有表Aport command表Bportcommand12345FG412343FG612345G表C现插入表C

关于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;
/

热点排行