(转)oracle的split函数
2024-10-15 16:49:09
本文转载自:http://www.cnblogs.com/linbaoji/archive/2009/09/17/1568252.html
PL/SQL 中没有split函数,需要自己写。
代码:
create or replace type type_split as table of varchar2(50); --创建一个 type ,如果为了使split函数具有通用性,请将其size 设大些。
--创建function create or replace function split ( p_list varchar2, p_sep varchar2 := ',' ) return type_split pipelined is l_idx pls_integer; v_list varchar2(50) := p_list; begin loop l_idx := instr(v_list,p_sep); if l_idx > 0 then pipe row(substr(v_list,1,l_idx-1)); v_list := substr(v_list,l_idx+length(p_sep)); else pipe row(v_list); exit; end if; end loop; return; end split;
测试:
SQL> select * from table(split('northsnow,塞北的雪',','));
COLUMN_VALUE
--------------------------------------------------
northsnow
塞北的雪
SQL>
补充:
-----PIPELINED关键字是什么意思?
---- pipe row是什么意思?
pipelined声名此function是pipe的,如果这么声名了,就必须使用pipe row的方式把数据返回,常规函数最后的"return 变量",就变成了"return".
pipelined的function主要是为了提高效率,不用等所有的数据都处理完成了才返回客户端,它是边处理边返回.适用于大数据量的交互.
最新文章
- js 时间相关函数
- Write a script to check an interesting game 6174
- 团队开发——冲刺1.f
- 原型模式(Prototype Pattern)
- #ifdef 和 #if defined 的区别 -- 转
- python之路-----MySql操作
- 总结Jquery中获取自定义属性使用.attr()和.data()以及.prop()的区别
- Java高级特性 第10节 IDEA和Eclipse整合JUnit测试框架
- Android so注入(inject)和Hook技术学习(三)——Got表hook之导出表hook
- HDU2853 Assignment KM
- 冒号课堂 编程范式与OOP思想
- mysql 冷热备份
- 牛客练习赛24题解(搜索,DP)
- canal入门Demo
- [转]HTML 简介
- cf-Global Round2-D. Frets On Fire(二分)
- jqgrid 编辑行、新增行、删除行、保存行
- C#.NET常见问题(FAQ)-public private protectd internal有什么区别
- java用String类的toUpperCase()和toLowerCase()方法转字符串的大小写
- getconf
热门文章
- selenium学习笔记(加入unittest)
- C++中GB2312字符串和UTF-8之间的转换
- ThinkPHP之MVC简析
- css中实现显示和隐藏(转)
- 通过IndexOf获得DataRow在DataTable中的行号
- Linux操作系统中的文件目录结构详细介绍
- nivicat premium连接阿里云数据库
- Qt之图形(QPainterPath)
- 《Drools7.0.0.Final规则引擎教程》第4章 4.2 activation-group& dialect& date-effective
- EasyDSS流媒体服务器出现no compatible source was found for this media问题的解决