自己写一个字符串分割函数
create or replace type split_tbl as table of varchar2(32767);
/
show errors;create or replace function split
(
p_list varchar2,
p_del varchar2 := ','
) return split_tbl pipelined
is
l_idx pls_integer;
l_list varchar2(32767) := p_list;
AA
l_value varchar2(32767);
begin
loop
l_idx := instr(l_list,p_del);
if l_idx > 0 then
pipe row(substr(l_list,1,l_idx-1));
l_list := substr(l_list,l_idx+length(p_del)); else
pipe row(l_list);
exit;
end if;
end loop;
return;
end split;
/
SQL> select * from table(split('one,two,three'));
one
two
three这样使用
SQL> select * from iptable
where input_ip
in (select iplist from table(split(iptable.ip_column)));
create or replace type split_tbl as table of varchar2(32767);
/
show errors;create or replace function split
(
p_list varchar2,
p_del varchar2 := ','
) return split_tbl pipelined
is
l_idx pls_integer;
l_list varchar2(32767) := p_list;
AA
l_value varchar2(32767);
begin
loop
l_idx := instr(l_list,p_del);
if l_idx > 0 then
pipe row(substr(l_list,1,l_idx-1));
l_list := substr(l_list,l_idx+length(p_del)); else
pipe row(l_list);
exit;
end if;
end loop;
return;
end split;
/
SQL> select * from table(split('one,two,three'));
one
two
three这样使用
SQL> select * from iptable
where input_ip
in (select iplist from table(split(iptable.ip_column)));
解决方案 »
- IMP-00037
- SQl语句查询速度的问题
- 请牛人指教,这个function有什么问题?
- 在oracle里怎么去掉回车苻。
- 请教pl/sql的帮助
- 各路老大,进来帮我看看,ORACLE关于SELECT的存储过程对不对?
- cpu占用率太大,系统运行接近死机!
- 怎么解决数据倒入时提示IMP-00016:不支持要求的字符集转换(从类型871到852)错误?
- ***启动OracleOraHome92TNSListener时,出现错误提示:系统找不到指定的路径。是怎么回事?**
- 关于oracle的经典教材的讨论
- rownum大于查询时无效
- 如何保证向两个不同字符集的ORACLE写数据或读数据的正确性?
这样可以
select * from iptable where instr(iplist,'192.168.0.7')>0
数据库中IP字段存在记录192.168.0.1,192.168.0.10
192.168.0.7只要满足在那个起始IP之间就可以。