问题描述
我想使用python cx_Oracle模块连接到oracle数据库。 当我尝试执行特定查询时,出现“ ORA-01847:每月的日期必须在1到该月的最后一天之间”
查询:
select case when to_date (STOP_DATE,'dd-mon-yy')='01-JAN-01' then '000000' else to_char(to_date(STOP_DATE,'dd-mon-yy'),'mmddyy') end STOP_DATE
from table1 where SYS_1= 1234 and rownum < 11
我们非常感谢您的帮助。
Python代码:
import cx_Oracle
connection = None
try:
dsn_tns = cx_Oracle.makedsn("host","port",service_name="serviceName")
connection = cx_Oracle.connect(user="user",password="password",dsn=dsn_tns)
c = connection.cursor()
sqlStatement = r'''
select case when to_date (STOP_DATE,'mmddyy') end STOP_DATE
from table1 where SYS_1= 1234 and rownum < 11
'''
c.execute(sqlStatement)
resultSet = c.fetchall()
if not len(resultSet) == 0:
print("query successful!!!!!!!!!!")
for row in resultSet:
for items in row:
if items == None:
items = ""
print (items)
if connection:
print('all executed')
connection.close()
except Exception as e:
print(e)
if connection:
connection.close()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)