oracle11g的regexp函数

1.判断是否是数字 regexp_Like

select * from (
select 'abc' s1 from dual
union all select '789456' s1 from dual
union all select '8907a7' s1 from dual
union all select '3' s1 from dual
union all select '' s1 from dual
union all select null s1 from dual
) where regexp_Like(s1,'^[0-9]+$')
;

2.指定字符是否在字符串存在  regexp_instr

--需求,为每笔交易的基金找个账号,优先取席位的专用账号,若多个席位匹配多个账号则随机取一个,没有席位的专用账号则取容错账号

drop table t_regexp_instr_account;

create table t_regexp_instr_account as

select '110001' fundid,'110001的专用账号1' accountno,'a001,b005,a002,d008' seatid from dual

union all select '110002','110002的容错账号','' from dual

union all select '110001','110001的容错账号','' from dual

union all select '110001','110001的c005专用账号','c005' from dual

union all select '110003','110003的b005专用账号','b005' from dual

union all select '110003','110003的容错账号','' from dual

union all select '110004','110004的a004专用账号','a004' from dual

union all select '110004','110004的容错账号','' from dual ;

drop table t_regexp_instr_trade;

create table t_regexp_instr_trade as

select '110001' fundid,'a002,c005' seatid from dual

union all select '110002' fundid,'a001' seatid from dual

union all select '110003' fundid,'c007,b006' seatid from dual

union all select '110004' fundid,'a004,b005' seatid from dual ;

--不用正则表达式

select * from t_regexp_instr_account a,t_regexp_instr_trade b where a.fundid=b.fundid and regexp_instr(a.seatid,b.seatid)>0 ;

--使用正则表达式可以达到效果 |代表或者

select * from (   select row_number() over (partition by a.fundid order by a.seatid nulls last) rid,a.* from t_regexp_instr_account a,t_regexp_instr_trade b   where a.fundid=b.fundid   and ( regexp_instr(a.seatid,replace(b.seatid,',','|'))>0 or a.seatid is null ) ) where rid=1 ;

 

转载于:https://www.cnblogs.com/jiangqingfeng/p/8961615.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值