简体   繁体   中英

How to handle xpath in SQL query while programming in Java

I am trying to execute the SQL statement from my java application

Due website restriction on url I have replaced http=htp for this post.

SELECT DISTINCT(DID) 
  FROM (SELECT e_id DID,
               xml_doc xml, 
               rownum rn from employee_master_indexes)," +
               " table(XMLSequence(extract(xml,'//cf:SalesReport/ext:Sales/*//j:PersonAssignedIDDetails/j:PersonID/j:ID',"+ 
              "'xmlns:j=\" htp://www.it.jvp.com/xmm/3.0.3\" 
                xmlns:xsi=\" htp://www.w3.org/2001/XMLSchema\" "  +   
               "xmlns:ext=\" htp://xml.crossflo.com/xdm/3.0.3/extension\" 
                xmlns:cf=\" htp://xml.crossflo.com/xdm/3.0.3\" ')))EMPID" +
              "WHERE extractValue(value(EMPID),'/j:ID', 'xmlns:j=\" htp://www.it.jvp.com/xmm/3.0.3\"')  LIKE '%-%-%' AND rn BETWEEN 999 AND 2001";

but end up with

10/05/24 11:11:51 java.sql.SQLException: ORA-00933: SQL command not properly ended 10/05/24 11:11:51 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) 10/05/24 11:11:51 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316) 10/05/24 11:11:51 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282) 10/05/24 11:11:51 at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639) 10/05/24 11:11:51 at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:113) 10/05/24 11:11:51 at oracle.jdbc.driver.T4CStatement.execute_for_describe(T4CStatement.java:431) 10/05/24 11:11:51 at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029) 10/05/24 11:11:51 at oracle.jdbc.driver.T4CStatement.execute_maybe_describe(T4CStatement.java:463) 10/05/24 11:11:51 at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126) 10/05/24 11:11:51 at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java :1274) 10/05/24 11:11:51 at oracle_jdbc_driver_T4CStatement_Proxy.executeQuery()

I am able to run this query properly on my sql prompt.Any guidance on what makes oracle give me this exception would be appreciated.

It looks like you are concatenating certain clauses to your SQL. Can you try putting it in a String and then do a system.out on it. Then take the output of system.out and trying running it exactly as is in your SQL command prompt. I bet you will quickly see the issue with the SQL there.

I second oedo, I have never seen SQL like this before!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM