Oracle中如何分隔字符串?

leonguo_1986 2007-10-10 03:09:54
就如JAVA中的split()方法一样,一个字符串以","间隔作为参数传入存储过程。
要在存储过程中进行分割,然后在操作。

谢谢谁能告诉我呀?
...全文
375 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
heyixiang 2007-10-11
  • 打赏
  • 举报
回复
详见http://blog.csdn.net/heyixiang/archive/2005/11/12/527973.aspx
nick216 2007-10-10
  • 打赏
  • 举报
回复
下午就写的这个
一个字 烦
nick216 2007-10-10
  • 打赏
  • 举报
回复
declare
str varchar2(100);
startposition number(10);
len number(10);
output varchar2(100);
begin
str:='hello,nick,xingxing';
startposition:=1;
loop
select instr(str,',',startposition ) into len from dual;
dbms_output.put_line(startposition);
dbms_output.put_line(len);

if len!=0 then
select substr(str,startposition,len-startposition) into output from dual;
else
select substr(str,startposition) into output from dual;
dbms_output.put_line(output);
exit;
end if;

dbms_output.put_line(output);
startposition:=len+1;
dbms_output.put_line('-------------------------------------');
end loop;

end;
leonguo_1986 2007-10-10
  • 打赏
  • 举报
回复
可以写个例子吗?我不熟悉呵呵
strSql = "1,2,3,4,5,6,7,8,9,10";
怎么循环出来?谢谢啦。。。
wangzk0206 2007-10-10
  • 打赏
  • 举报
回复
instr + substr

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧