0

I am trying to retrieve xml value from a column with data stored in xml format using below query in Oracle SQL Developer. But getting this error:

ORA-00932: inconsistent datatypes: expected - got - 00932. 00000 - "inconsistent datatypes: expected %s got %s" *Cause:

Data type of column is CLOB

 SELECT id, 
   extractValue(e.event_data, '/DocumentRequest/RequestUserName')
   "Number of Docks"
   FROM table e

eg:

<DocumentRequest>
    <RequestUserName>XXXX</RequestUserName>
    <RequestDateTime>XXXX</RequestDateTime>
    <DocSequence>1</DocSequence>
1
  • are you sure e.event_data is of type XMLTYPE? Commented Jan 27, 2021 at 15:07

1 Answer 1

1

If the XML is stored as CLOB, then take XMLTYPE:

SELECT id,
       EXTRACTVALUE( XMLTYPE(e.event_data), '/DocumentRequest/RequestUserName') AS "Number of Docks"
  FROM table e;

Query which uses XMLTABLE:

SELECT id,
       col1 AS "Number of Docks"
  FROM table e, XMLTABLE( '/DocumentRequest'
                  PASSING XMLTYPE(e.event_data)
                  COLUMNS col1 PATH 'RequestUserName' );
Sign up to request clarification or add additional context in comments.

1 Comment

Note: The EXTRACTVALUE function is deprecated.Use the XMLTABLE function.

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.