ORA-00933: SQL命令未正确结束 – WHERE子句

huangapple go评论80阅读模式
英文:

ORA-00933: SQL command not properly ended - WHERE clause

问题

我已将以下查询存储在一个字符串中,以请求我的 OracleDB:

"SELECT firstname, lastname, COUNT(kids)  
FROM test_table  
WHERE firstname in ('mario',  'peter')  
GROUP BY firstname, lastname
ORDER BY firstname, lastname;"

当我通过我的Java应用程序和JDBC执行查询时,我收到以下错误:

Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended

	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
	at oracle.jdbc.driver.OracleStatement.executeForDescribe(T4CStatement.java:876)
	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1175)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
	at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
	at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
	at com.foo.test.App.main(App.java:30)
英文:

I have stored the following query in a String to request my OracleDB:

"SELECT firstname, lastname, COUNT(kids)  
FROM test_table  
WHERE firstname in ('mario',  'peter')  
GROUP BY firstname, lastname
ORDER BY firstname, lastname;"

When I execute the query via my Java Application and JDBC I get the following error:

Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended

	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
	at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:876)
	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1175)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
	at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
	at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
	at com.foo.test.App.main(App.java:30)

答案1

得分: 6

在这里移除分号:

ORDER BY firstname, lastname;"
                            ^
                            |
英文:

Remove semi-colon, here:

ORDER BY firstname, lastname;"
                            ^
                            |

huangapple
  • 本文由 发表于 2020年9月11日 15:51:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/63842922.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定