佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > Oracle中instr和substr存儲過程詳解

Oracle中instr和substr存儲過程詳解

熱門標(biāo)簽:網(wǎng)站排名優(yōu)化 Linux服務(wù)器 呼叫中心市場需求 鐵路電話系統(tǒng) 服務(wù)外包 百度競價(jià)排名 AI電銷 地方門戶網(wǎng)站

instr和substr存儲過程,分析內(nèi)部大對象的內(nèi)容

instr函數(shù)

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

用于查找內(nèi)部大對象中的字符串的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為內(nèi)部大對象的定位器

pattern是要匹配的模式

offset是要搜索匹配文件的開始位置

nth是要進(jìn)行的第N次匹配

 substr函數(shù)

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

操作內(nèi)部大對象的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;

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

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

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

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

如果從大型對象中抽取數(shù)據(jù)成功,則這個(gè)函數(shù)返回一個(gè) 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:8
The first occurrence starts at position:24
The substring extracted is: Oracle 9i

PL/SQL 過程已成功完成。

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

您可能感興趣的文章:
  • Oracle 存儲過程加密方法
  • oracle 存儲過程加密的方法
  • oracle下加密存儲過程的方法
  • Oracle存儲過程和存儲函數(shù)創(chuàng)建方法(詳解)
  • Oracle存儲過程及調(diào)用
  • oracle中 procedure(存儲過程)和function(函數(shù))本質(zhì)區(qū)別
  • windows中oracle存儲過程加密的實(shí)例代碼

標(biāo)簽:衡水 仙桃 蘭州 湘潭 銅川 黃山 湖南 崇左

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle中instr和substr存儲過程詳解》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    台湾省| 柘荣县| 山东| 壤塘县| 罗甸县| 鹤山市| 娱乐| 青岛市| 晋州市| 开阳县| 昆山市| 北京市| 盐亭县| 湖州市| 鲜城| 佳木斯市| 揭西县| 冀州市| 南康市| 黄龙县| 广宗县| 霸州市| 原阳县| 井冈山市| 镇远县| 霍城县| 满城县| 滨海县| 上虞市| 临江市| 河东区| 疏勒县| 德庆县| 分宜县| 边坝县| 万安县| 白沙| 高淳县| 华安县| 蓬莱市| 桑日县|