Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert XMLType to clob/varchar

user566910Apr 2 2007 — edited Feb 12 2010
I have the following table containing a XMLTYPE column
create table contracts( id number primary key, contract_doc XMLTYPE) XMLTYPE contract_doc store as clob;

Now in a query to get the xml value as a VARCHAR or clob I could do the following:
SELECT c.CONTRACT_DOC.getStringVal() FROM CONTRACTS c
SELECT c.CONTRACT_DOC.getClobVal() FROM CONTRACTS c
respectively.

Also explained here 490299

However, the SQL statement is Oracle-specific. Is there another way that is database neutral ?

I have also tried "SELECT CONTRACT_DOC AS CLOB FROM CONTRACTS".
However, in my java code Clob clob = rs.getClob(i);
results in the following error message "Invalid column type: getCLOB not implemented for class oracle.jdbc.driver.T4CNamedTypeAccessor"

So far to get the XML data requires the following code:
XMLType poxml = (XMLType) rs.getObject(i);
String xmlValue = poxml.getStringVal();
which again is Oracle-specific.

Any help would be appreciated. Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2010
Added on Apr 2 2007
7 comments
47,628 views