简体   繁体   English

cx_Oracle 查询:ORA-00933:SQL 命令未正确结束

[英]cx_Oracle queries: ORA-00933: SQL command not properly ended

cur.execute(""" SELECT location, AVG(temp) as avg_temp FROM (SELECT location,temp, ROWNUM rnum FROM time_series_location_temp ORDER BY avg_temp ASC) WHERE rnum <= 6; """) I'm trying to execute this code but keep running into this error DatabaseError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_17344/3055250712.py in ----> 1 cur.execute(""" 2 SELECT LOCATION_ID, AVG(temp) as avg_temp 3 FROM (SELECT LOCATION_ID,temp 4 FROM time_series_location_temp 5 ORDER BY temp ASC) cur.execute(""" SELECT location, AVG(temp) as avg_temp FROM (SELECT location,temp, ROWNUM rnum FROM time_series_location_temp ORDER BY avg_temp ASC) WHERE rnum <= 6; """) 我正在尝试执行这段代码但继续遇到此错误 DatabaseError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_17344/3055250712.py in ----> 1 cur.execute(""" 2 SELECT LOCATION_ID, AVG(temp) as avg_temp 3 FROM (SELECT LOCATION_ID,temp 4 FROM time_series_location_temp 5 ORDER BY temp ASC)

DatabaseError: ORA-00933: SQL command not properly ended DatabaseError: ORA-00933: SQL 命令未正确结束

What's wrong and how should I re-write it?出了什么问题,我应该如何重写它?

I've tries to rewrite it and still the error comes up.我试图重写它,但仍然出现错误。 I was expecting that the code would run and execute my query correctly我期待代码能够运行并正确执行我的查询

That error almost invariably means that you have left the semicolon on the end of the statement.该错误几乎总是意味着您在语句末尾留下了分号。 This is needed in SQL*Plus but needs to be removed when using cx_Oracle (or the new python-oracledb).这在 SQL*Plus 中是必需的,但在使用 cx_Oracle(或新的 python-oracledb)时需要删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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