instr和substr存储过程,分析内部大对象的内容

instr函数与substr函数
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 过程已成功完成。

作者:hellofei

dbms_lob包学习笔记之三:instr和substr存储过程的更多相关文章

  1. R parallel包学习笔记2

    这个部分我在datacamp上面学习笔记,可视化的性能很差,使用的函数也很少. 可以参考一下大佬的博客园个人感觉他们讲的真的很详细 https://cosx.org/2016/09/r-and-par ...

  2. Django 学习笔记之三 数据库输入数据

    假设建立了django_blog项目,建立blog的app ,在models.py里面增加了Blog类,同步数据库,并且建立了对应的表.具体的参照Django 学习笔记之二的相关命令. 那么这篇主要介 ...

  3. 【Visual C++】游戏编程学习笔记之三:游戏循环的使用

     本系列文章由@二货梦想家张程 所写,转载请注明出处. 本文章链接:http://blog.csdn.net/terence1212/article/details/44208419 作者:Zee ...

  4. R Tidyverse dplyr包学习笔记2

    Tidyverse 学习笔记 1.gapminder 我理解的gapminder应该是一个内置的数据集 加载之后使用 > # Load the gapminder package > li ...

  5. hive学习笔记之三:内部表和外部表

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  6. Netty4 学习笔记之三:粘包和拆包

    前言 在上一篇Netty 心跳 demo 中,了解了Netty中的客户端和服务端之间的心跳.这篇就来讲讲Netty中的粘包和拆包以及相应的处理. 名词解释 粘包: 会将消息粘粘起来发送.类似吃米饭,一 ...

  7. pandas包学习笔记

    目录 zip Importing & exporting data Plotting with pandas Visual exploratory data analysis 折线图 散点图 ...

  8. 【Java学习笔记之三十一】详解Java8 lambda表达式

    Java 8 发布日期是2014年3月18日,这次开创性的发布在Java社区引发了不少讨论,并让大家感到激动.特性之一便是随同发布的lambda表达式,它将允许我们将行为传到函数里.在Java 8之前 ...

  9. 【Java学习笔记之三十四】超详解Java多线程基础

    前言 多线程并发编程是Java编程中重要的一块内容,也是面试重点覆盖区域,所以学好多线程并发编程对我们来说极其重要,下面跟我一起开启本次的学习之旅吧. 正文 线程与进程 1 线程:进程中负责程序执行的 ...

随机推荐

  1. 在ensp上的OSPF

    实验模拟 搭建实验拓扑 测试连通性 部署单区域OSPF网络 默认ospf 进程号为1 ,接着使用area命令创建区域并进入ospf区域视图  ,因为是单区域配置,所以使用骨干区域,即0区域 检查osp ...

  2. Linux安装zookeeper3.5.6

    依赖JRE[我这边是JRE8] 一,先在https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/下载apache-zookeeper- ...

  3. Java byte和hex十六进制字符串转换

    在Java中字符串由字符char组成, 一个char由两个byte组成, 而一个byte由八个bit组成, 一个十六进制字符(0-F)实际上由4个字节byte即可表达, 因此, 从字节数组到十六进制字 ...

  4. day13——重要内置函数、匿名函数、闭包

    day13 内置函数2 重要的 abs():求绝对值--返回的都是正数 # lst = [-1,-2,-3] # for i in lst: # print(abs(i)) # print([abs( ...

  5. Function Evaluation

    Author: Leisureeen Time Limit: 100ms Memory Limit: 65535KB Code Size Limit: 16 KB 64-bit integer IO ...

  6. sublime_python编译_输出台中文为乱码

    Evernote Export sublime_python编译_输出台中文为乱码 创建时间: 2019-10-17 星期四 10:52 作者: 苏苏 标签: sublime, 乱码       问题 ...

  7. Mybatis自动生成代码工具

    项目结构如下 一:在POM中添加mybatis-generator-maven-plugin 插件 <plugins> <plugin> <groupId>org. ...

  8. Spring-Cloud之Zuul路由网关-6

    一.为什么需要Zuul? Zuul 作为微服务系统的网关组件,用于构建边界服务( Edge Service ),致力于动态路由.过滤.监控.弹性伸缩和安全.Zuul 作为路由网关组件,在微服务架构中有 ...

  9. Django之创建超级用户

    本文链接来自:https://blog.csdn.net/HuaCode/article/details/79721673 首选创建一个新用户,用来登录Django管理网站,进入manage.py目录 ...

  10. SpringBoot之多Profile配置

    近来在利用闲暇时间巩固下SpringBoot的基本知识,然后自己也做一些笔记,整理下当时所学知识,后面就干脆写到这里来了. 多Profile配置文件 在SpringBoot主配置文件编写的时候,文件名 ...