我尝试使用 python、cx_oracle 运行此 SQL 查询,但收到 ORA-01830 错误
splited_date = (fecha.year, fecha.month, fecha.day)
print("flag {}{:02d}{:02d}".format(*splited_date))
while flag == 1:
cursor = conn.cursor()
print(fecha.strftime('%Y-%m-%d'))
try:
print('Filling...')
formatted_date = fecha.strftime('%Y-%m-%d')
sql_query = "BEGIN PK_NAME(TO_DATE(:1, 'YYYY-MM-DD HH:MI')); END;"
cursor.execute(sql_query, [formatted_date])
print("table_proc")
flag = 2
except Exception as error:
print(error)
flag = 1
print("Filling finished.")
您的格式包含年月日时分,但您提供的格式化日期仅包含年月日!所以错误
ORA-01830: Date format picture ends before converting entire input string.
是有道理的!您需要修复该差异,或者更好的是,避免日期转换并直接绑定日期值!