extractvalue處理XMLTYPE型別超過4000位元組ORA-01706的解決方法
extractvalue在處理XMLTYPE型別運算時非常方便,但在處理超過4000位元組column就力不從心了。
問題:
一位朋友在Oracle中使用extractvalue處理XMLTYPE型別時,發現column值超過4000位元組時就會報錯ORA-01706.
是否真會這樣呢?
透過實驗重現問題:
1.建立XML table
Create TABLE testxml( id NUMBER, data XMLTYPE );
2.建立目錄
CREATE OR REPLACE DIRECTORY EXPDP_DIR AS '/data/expdp_dir/';
3.在目錄/data/expdp_dir/ 中建立11.xml檔案, 模擬Data2長度為4001位元組,檔案內容如下:
<Workbook> <Row> <Data1>MES</Data1> <Data2>01234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340123401234012340</Data2> </Row> </Workbook>
4.透過bfile方式insert資料
insert into testxml(id,data) values(6,xmltype(bfilename('EXPDP_DIR','11.xml'),nls_charset_id('AL32UTF8'))); commit;
5.檢視insert後資料
select *from testxml
6.使用extractvalue查詢小於4000位元組column Data1,可以正常返回結果
select extractvalue(data,'/Workbook/Row/Data1') from testxml;
7 . 使用 extractvalue 查詢大於4000位元組column Data2,出現報錯 ORA-01706
select extractvalue(data,'/Workbook/Row/Data2') from testxml;
以上證實extractvalue無法處理大於4000位元組column
解決:
檢視Oracle官方文件對extractvalue函式的介紹
The
EXTRACTVALUE
function is deprecated. It is still supported for backward compatibility. However, Oracle recommends that you use the
XMLTABLE
function, or the
XMLCAST
and
XMLQUERY
functions instead. See
,
, and
for more information.
原來官方已建議不要再使用extractvalue,而建議使用XMLTABLE,XMLCASE,XMLQUERY函式
繼續查閱XMLTABLE使用文件
利用XMLTABLE函式處理大於4000位元組column:
SELECT * FROM testxml,XMLTABLE('/Workbook' PASSING testxml.data COLUMNS CON clob PATH '/Workbook/Row/Data2' )
在XMLTABLE可以自定義字元型別,這裡指定clob型別可成功獲取超過4000位元組資料
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25583515/viewspace-2687485/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 19c varchar2超過4000位元組處理Oracle
- Oracle Xmltype型別淺析OracleXML型別
- 單位元組處理函式函式
- Qt 大小端位元組序的處理QT
- int型別按位元組列印輸出型別
- Java基本型別佔用的位元組數(char佔用幾個位元組問題)Java型別
- Java char 型別究竟佔幾個位元組?Java型別
- java中基本型別佔用位元組數Java型別
- Oracle 12c資料庫擴充套件VARCHAR2欄位屬性超過4000位元組Oracle資料庫套件
- 字元型別的字元儲存與位元組儲存字元型別
- ORACLE 資料型別佔用的位元組數(轉)Oracle資料型別
- 讓Dapper+SqlCE支援ntext資料型別和超過4000字元的儲存APPSQL資料型別字元
- pymysql 處理 連線超時最好的解決方案MySql
- SpringMVC(二)處理器方法繫結形參(簡單型別和註解@RequestParam,pojo型別)、自定義型別轉換器、springMVC亂碼解決SpringMVC型別POJO
- MyBatis(九):MyBatis型別處理器(TypeHandler)詳解MyBatis型別
- 自定義聚集函式,仿wm_concat,使用CLOB,可處理超過4000長度字串函式字串
- 解決 requests 庫中的位元組物件問題物件
- 檔案輸入輸出處理(二)-位元組流
- 化解字串不能超過8000的方法及交叉表的處理字串
- Java反射獲取位元組碼以及判斷型別Java反射型別
- byte位元組陣列 轉換成double型別陣列型別
- mysql處理varchar型別的between和and的時間問題少一天解決;MySql型別
- Oracle LOB資料型別的處理Oracle資料型別
- Numpy庫基礎分析——詳解datetime型別的處理型別
- android方法數超過64K的解決方案Android
- 處理器負荷過大怎麼解決
- spring-redis SortedSet型別成員的過期時間處理SpringRedis型別
- 處理分頁的result型別問題型別
- ORA-600[4000]/[4097]錯誤的處理
- 程式錯誤型別及其處理型別
- CXF--處理複雜型別型別
- SSL證書報錯型別及解決方法型別
- 位元組碼詳解
- Java提高篇(二):IO位元組流、字元流和處理流Java字元
- 多型關聯自定義的型別欄位的處理多型型別
- 【ORA-02049】超時分散式事務處理等待鎖 解決方法 推薦分散式
- 組合模式-統一的處理個別物件與組合物件模式物件
- ETLCloud支援的資料處理型別包括哪些?Cloud型別