在Plsql中没有问题,但是在java中报错:sql命令未正确结束 50
代码如下:PreparedStatementpst=c.prepareStatement("selectdistinctt.name,t.num,t.price,tt.c...
代码如下:
PreparedStatement pst = c.prepareStatement
("select distinct t.name,t.num,t.price,tt.ccount from " +
"(select data,name,num,price from turnover1 where data = "+data+")as t," +
"(select num,sum(count) ccount from turnover1 where data = "+data+" group by num) as tt " +
"where tt.num = t.num ");
ResultSet rs = pst.executeQuery();
报错:
java.sql.SQLException: ORA-00933: SQL 命令未正确结束
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
。。。。。 展开
PreparedStatement pst = c.prepareStatement
("select distinct t.name,t.num,t.price,tt.ccount from " +
"(select data,name,num,price from turnover1 where data = "+data+")as t," +
"(select num,sum(count) ccount from turnover1 where data = "+data+" group by num) as tt " +
"where tt.num = t.num ");
ResultSet rs = pst.executeQuery();
报错:
java.sql.SQLException: ORA-00933: SQL 命令未正确结束
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
。。。。。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询