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



我试图用cx_Oracle运行语句,我不断得到问题,它说SQL命令没有正确结束,但阅读文档后似乎这是正确的,但实际上这是不正确的。cx_Oracle.DatabaseError: ORA-00933 SQL command not properly ended

vary = "'Y'"
dsn_tns = cx_Oracle.makedsn(hostName, port,
service_name=serviceName) 
conn = cx_Oracle.connect(user=usr, password=__pswrd,
dsn=dsn_tns) 
c = conn.cursor()  
tempCheck = "'%{0}/%'".format(checkerAR)
statmentApp = 'SELECT TITLE,APP_URL from SOME.DATABASE' 
'WHERE UPPER(APP_URL) LIKE UPPER(:tc)' 
'AND ACTIVE_FLAG = :y'
c.execute(statmentApp,tc = tempCheck , y = vary)

c.execute行是错误被标记的地方。我试图在tempCheck进入语句,因为我想添加通配符到SQL语句。我哪里做错了?

print (statmentApp)

给:

SELECT TITLE,APP_URL from SOME.DATABASEWHERE UPPER(APP_URL) LIKE UPPER(:tc)AND ACTIVE_FLAG = :y

表示字符串连接工作得太好了。为了保留必要的空白,您会发现使用三引号更容易:

statmentApp = """SELECT TITLE,APP_URL from SOME.DATABASE
WHERE UPPER(APP_URL) LIKE UPPER(:tc)
AND ACTIVE_FLAG = :y"""

相关内容

  • 没有找到相关文章

最新更新