This content has been marked as final. Show 1 reply
I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
select dbms_xmlgen.getxml(select * from departments) from dual
please some one help with appropriate java code to execute it.
Java code? You can't execute that query at all since it is invalid. The parameter needs to be a query string NOT a query.
See the DBMS_XMLGEN package in the docs
select dbms_xmlgen.getxml('select * from departments') from dual
Converts the results from the SQL query string to XML format, and returns the XML as a temporary CLOB, which must be subsequently freed using the DBMS_LOB.FREETEMPORARY call:
sqlQuery IN VARCHAR2,
dtdOrSchema IN number := NONE)
Then you execute that query like any other query that returns a result set. The result set will consist of one row and one column of CLOB datatype.
See the JDBC Developer's Guide - it has examples of how to execute queries that return result sets.
And this section shows how tow read/write CLOBs