1

I have an oracle column with a long data type that stores an xml. Now I want to perform the EXTRACT and EXTRACTVALUE functions on this column. For this purpose, I need to convert the long to xmltype. But when I do : xmltype.createxml(long_col_name), I get :illegal use of long datatype
I know long is deprecated, but it is legacy db.So...

EDIT: Upon the suggestion, i tried:

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

I get:

[Error] Execution (2: 24): ORA-00932: inconsistent datatypes: expected - got LONG
1
  • maybe first convert to CLOB - then to XML Commented Aug 17, 2012 at 16:08

2 Answers 2

1

Check this link good example

in short you need to do the following:

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%';

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

0

you'd better to migrate the LONG column type to CLOB. It will also benefit you in future. then you can use xmltype on the CLOB column.

1 Comment

Welcome to SO. Feel bad about downvoting...but your answer is not helpful to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.