python - 为 DATETIME 创建 cx_Oracle arrayvar

标签 python datetime cx-oracle

我想为日期时间创建一个 cx_Oracle arrayvar,然后我可以用它来提供 callproc。所以我期望的代码是这样的:

dt1 = datetime.datetime.strptime('2012/07/30 10:42:09', '%Y/%m/%d %H:%M:%S')
dt2 = ...(another datetime value)...
av1 = cursor.arrayvar(cx_Oracle.DATETIME, [dt1, dt2])
av2 = ...(another arrayvar)...
cursor.callproc('my_db_procedure', (av1, av2))

但是我不断收到此错误:

PLS-00306: wrong number or types of arguments in call to 'my_db_procedure'

有人可以指出我做错了什么吗?

最佳答案

好吧,我终于发现问题所在了。在我的 PL/SQL 代码中,我将输入参数类型定义为:

TYPE id IS TABLE OF varchar2(16);

实际上应该是:

TYPE id IS TABLE OF varchar2(16) INDEX BY BINARY_INTEGER;

我希望这可以帮助有类似问题的人。

关于python - 为 DATETIME 创建 cx_Oracle arrayvar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12976745/

相关文章:

python - 使用函数从指定索引开始对 Python 中不同长度的列表求和

python - 在 IPython 中控制列表可视化

java - 与 Joda 时间 DateTime# centuryOfEra() 的混淆

javascript - 将任何类型的日期格式转换为 MM\DD\YYYY

python - cx_Oracle : How do I iterate over a result set?

python - 接口(interface)错误 : Unable to acquire Oracle environment handle; ORACLE_HOME is correct and SQL*Plus will connect

python - 在 Twisted 中使用 callLater 来跟踪拍卖结束

mysql - 如何加快 MySQL 中 'where MATCH AGAINST and DATETIME' 搜索的速度?

python - cx_Oracle.InterfaceError : Unable to acquire Oracle environment handle in linux

python - 转换数据框以进行网络绘图