国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

Oracle中instr和substr存儲過程詳解

2024-08-29 13:59:42
字體:
來源:轉載
供稿:網(wǎng)友

instr和substr存儲過程,分析內部大對象的內容

instr函數(shù)

instr函數(shù)用于從指定的位置開始,從大型對象中查找第N個與模式匹配的字符串。

用于查找內部大對象中的字符串的instr函數(shù)語法如下:

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函數(shù)

substr函數(shù)用于從大對象中抽取指定數(shù)碼的字節(jié)。當我們只需要大對象的一部分時,通常使用這個函數(shù)。

操作內部大對象的substr函數(shù)語法如下:

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;

其中各個參數(shù)的含義如下:

lob_loc是substr函數(shù)要操作的大型對象定位器

amount是要從大型對象中抽取的字節(jié)數(shù)

offset是指從大型對象的什么位置開始抽取數(shù)據(jù)。

如果從大型對象中抽取數(shù)據(jù)成功,則這個函數(shù)返回一個 raw 值。如果有一下情況,則返回null:

 1 任何輸入?yún)?shù)尾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:8The first occurrence starts at position:24The substring extracted is: Oracle 9i

PL/SQL 過程已成功完成。

以上所述是小編給大家介紹的Oracle中instr和substr存儲過程詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VeVb武林網(wǎng)網(wǎng)站的支持!


注:相關教程知識閱讀請移步到oracle教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 固安县| 黄浦区| 景宁| 武冈市| 葵青区| 大余县| 五寨县| 博乐市| 柘城县| 玛纳斯县| 德格县| 盘山县| 托里县| 呼图壁县| 宜兰市| 碌曲县| 延边| 亚东县| 乌苏市| 舞钢市| 绥中县| 天柱县| 临邑县| 化德县| 长子县| 枣庄市| 民勤县| 宁武县| 舒兰市| 金坛市| 舞钢市| 长春市| 阿瓦提县| 盈江县| 蓬安县| 宁明县| 新宾| 朝阳市| 包头市| 南部县| 玉树县|