Hi, How to get xml attribute using Apache Derby?
I was doing it like this, but it's not working. I've created table using: create table xml_orders (xml_col xml) Then I inserted value to its doing: INSERT INTO xml_orders VALUES ( XMLPARSE(DOCUMENT ' <orders> <singleOrder no="1" date="2015-01-22"> </singleOrder> </orders> 'PRESERVE WHITESPACE) ) But when I'm doing query like this: SELECT XMLSERIALIZE( XMLQUERY('//singleOrder/@date' PASSING BY REF xml_col EMPTY ON EMPTY) AS VARCHAR(1000) )AS CustomerId FROM xml_orders I'm getting error: Caused by: ERROR 2200W: XQuery serialization error: Attempted to serialize one or more top-level Attribute nodes. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.iapi.types.XML.XMLSerialize(Unknown Source) at org.apache.derby.exe.ac23ffc05bx0150xf290x866cx000006bfe7900.e0(Unknown Source) at org.apache.derby.impl.services.reflect.DirectCall.invoke(Unknown Source) at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.doProjection(Unknown Source) at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(Unknown Source) at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(Unknown Source) ... 38 more Thank you, Greg