Oracle中instr和substr存储过程详解
instr和substr存储过程,分析内部大对象的内容
instr函数
instr函数用于从指定的位置开始,从大型对象中查找第N个与模式匹配的字符串。
用于查找内部大对象中的字符串的instr函数语法如下:
dbms_lob.instr( lob_loc in blob, pattern in raw, offset in integer := 1; nth in integer := 1) return integer; dbms_lob.instr( lob_loc in clob character set any_cs, pattern in varchar2 character set lob_loc%charset, offset in integer:=1, nth in integer := 1) return integer;
lob_loc为内部大对象的定位器
pattern是要匹配的模式
offset是要搜索匹配文件的开始位置
nth是要进行的第N次匹配
substr函数
substr函数用于从大对象中抽取指定数码的字节。当我们只需要大对象的一部分时,通常使用这个函数。
操作内部大对象的substr函数语法如下:
dbms_lob.substr( lob_loc in blob, amount in integer := 32767, offset in integer := 1) return raw; dbms_lob.substr( lob_loc in clob character set any_cs, amount in integer := 32767, offset in integer := 1) return varchar2 character set lob_loc%charset;
其中各个参数的含义如下:
lob_loc是substr函数要操作的大型对象定位器
amount是要从大型对象中抽取的字节数
offset是指从大型对象的什么位置开始抽取数据。
如果从大型对象中抽取数据成功,则这个函数返回一个 raw 值。如果有一下情况,则返回null:
1 任何输入参数尾null
2 amount < 1
3 amount > 32767
4 offset < 1
5 offset > LOBMAXSIZE
示例如下:
declare source_lob clob; pattern varchar2(6) := 'Oracle'; start_location integer := 1; nth_occurrence integer := 1; position integer; buffer varchar2(100); begin select clob_locator into source_lob from mylobs where lob_index = 4; position := dbms_lob.instr(source_lob, pattern, start_location, nth_occurrence); dbms_output.put_line('The first occurrence starts at position:' || position); nth_occurrence := 2; select clob_locator into source_lob from mylobs where lob_index = 4; position := dbms_lob.instr(source_lob, pattern, start_location, nth_occurrence); dbms_output.put_line('The first occurrence starts at position:' || position); select clob_locator into source_lob from mylobs where lob_index = 5; buffer := dbms_lob.substr(source_lob, 9, start_location); dbms_output.put_line('The substring extracted is: ' || buffer); end; / The first occurrence starts at position:8 The first occurrence starts at position:24 The substring extracted is: Oracle 9i
PL/SQL 过程已成功完成。
原文链接:http://www.cnblogs.com/hellofei/archive/2010/03/25/1695363.html
(资源库 www.zyku.net)
上一篇:返回列表
栏 目:Oracle
下一篇:Linux中Oracle启动侦听报错TNS:permission denied的解决方法
本文标题:Oracle中instr和substr存储过程详解
本文地址:https://www.zyku.net/oracle/608.html
您可能感兴趣的文章
- 05-05SQLServer 2016安装时的错误:Polybase要求安装Oracle J
- 03-16oracle 删除重复记录
- 02-18详解ORACLE SEQUENCE用法
- 02-18Oracle使用触发器和mysql中使用触发器的案例比较
- 02-18Oracle 中 table 函数的应用浅析
- 02-18Oracle中转义字符的详细介绍
- 02-18Oracle 自定义split 函数实例详解
- 02-18Oracle数据库用户的密码过期时间如何修改为永不过期
- 02-18oracle中添加删除主键的方法
- 02-18修改Oracle监听默认端口号1521的方法
- 01-10远离中风-远离中风应用软件功能介绍
- 11-04夸克浏览器播放记录如何删除
- 02-18真我gtneo手机投屏到电视操作方法
- 11-23小米手机怎么设置快充模式
- 03-30vivo微信视频聊天美颜设置方法
- 02-13Python Django框架介绍之模板标签及模
- 01-12中国蓝新闻客户端-中国蓝新闻客户端应
- 10-30QQ新增个人信息隐私保护功能介绍
- 09-19猫耳fm弹幕屏蔽词在哪里添加
- 01-16网速在线测速-网速在线测速应用软件功
最近更新
阅读排行
猜你喜欢
- 03-30redmik40分屏及截图操作步骤教程
- 12-28录音转文字助理-录音转文字助理应用软
- 12-30众禾慧农-众禾慧农应用软件功能介绍
- 04-20一加9pro应用隐藏图标教程
- 02-20notepad++设置默认为UTF-8无BOM格式
- 09-18百度搜索相关API
- 12-10iphone se2如何开启指纹密码锁屏
- 10-26goodnotes5复制pdf文字方法分享
- 02-10python实现电脑操控安卓手机
- 10-20mooda添加小组件设置方法分享