CREATE OR REPLACE Function VIPJF.Get_Field_Value(in_str IN varchar2,findstr in varchar2, field in integer )
return varchar2
AS
tmp_msg varchar2(20);
-- 取字段 值 ,field start from 0
startidx integer;
endidx integer;
begin
startidx := 1;
endidx := 1;
for i in 1..field loop
--INSTR(in_string,'|',tmp_pos);
--substr(in_string,tmp_pos,tmp_pos1-tmp_pos);
if i > 1 then
startidx := INSTR(in_str,findstr,startidx);
if startidx = 0 then return null; end if;
startidx := startidx + length(findstr);
end if;
end loop;
endidx := INSTR(in_str,findstr,startidx);
if endidx = 0 then endidx := length(in_str)+1; end if;
return substr(in_str,startidx,endidx - startidx);
exception when others then
return null ;
end;
参考下
in_trade_code := Get_Field_Value(tmp_instr,'|',1);
Tags: oracle数据库 sql编程
原创文章如转载,请注明:转载自:飞扬部落编程仓库 : http://www.busfly.net/csdn/
本文链接地址:http://www.busfly.net/csdn/post/313.html
如果你喜欢本文,请顶一下,支持我,你的支持是我继续发好文章的最大动力。谢谢。
好东西需要分享,快把本文发给你的朋友吧~!~