2012-08-17 79 views
1

我有一個長列數據類型的oracle列,用於存儲xml。現在我想對此列執行EXTRACTEXTRACTVALUE函數。爲此,我需要將long轉換爲xmltype。但是,當我這樣做:xmltype.createxml(long_col_name),我得到:illegal use of long datatype
我知道長已經過時,但它是傳統db.So ...無法在oracle中將長數據類型轉換爲xml

編輯:在建議下,我想:

SELECT 
EXTRACTVALUE(XMLTYPE (to_lob(long_col_name)), xpath_str) as value_date 
FROM table_1; 

我得到:

[Error] Execution (2: 24): ORA-00932: inconsistent datatypes: expected - got LONG 
+0

可能首先轉換爲CLOB - 然後轉換爲XML – Randy 2012-08-17 16:08:52

回答

-1

您最好將LONG列類型遷移到CLOB。它也將在未來受益。那麼你可以在CLOB列上使用xmltype。

+0

歡迎來到SO。對降低投票感覺不好......但你的回答對我沒有幫助。 – Victor 2012-08-17 17:46:46

+0

如果我的回答沒有幫助,請忽略它。 – burnDB 2012-09-07 18:36:34

1

檢查此鏈接 good example

總之,你需要做到以下幾點:

with xml as 
    (select dbms_xmlgen.getxmltype('select long_col_name from table_1') as xml from dual) 

    select extractValue(xs.object_value,'/ROW/long_col_name') as value_date 
    from xml x, table(xmlsequence(extract(x.xml,'/ROWSET/ROW'))) xs 
    where extractValue(xs.object_value,'/ROW/long_col_name') like '%xxxx%'; 

希望這有助於。