简体   繁体   English

使用Python的cx_oracle callproc函数获取错误

[英]Getting an error with Python's cx_oracle callproc function

I have this code: 我有以下代码:

        curs.callproc('add_command_pkg.add_command', [],
                      { 'command_id' : 7,
                        'session_id' : None,
                        'expiry_time' : 'sysdate + 7',
                        'config_id' : 6 })

When I run this, I get this error: 运行此命令时,出现以下错误:

File "N:\\app\\MainWidget.py", line 453, in myFunc myFunc中的文件“ N:\\ app \\ MainWidget.py”,第453行
curs.callproc('add_command_pkg.add_command', [], { 'command_id' : 7, 'session_id' : None, 'expiry _time' : 'sysdate + 7', 'config_id' : 6 }) curs.callproc('add_command_pkg.add_command',[],{'command_id':7,'session_id':无,'expiry _time':'sysdate + 7','config_id':6})
cx_Oracle.DatabaseError: ORA-01858: a non-numeric character was found where a nu meric was expected ORA-06512: at line 1 cx_Oracle.DatabaseError:ORA-01858:在第1行找到了一个非数字字符,期望的数字为ORA-06512:

What parameter am I passing in wrong and how do I fix it? 我输错了什么参数,我该如何解决?

edit: 编辑:

command signature: 命令签名:

                                        ( command_id   IN NUMBER,
                                          expiry_time  IN DATE,
                                          session_id   IN NUMBER DEFAULT NULL,
                                          config_id    IN NUMBER DEFAULT NULL
                                        );

Also, how do I commit this? 另外,我该如何提交?

You can't pass in the string 'sysdate + 7' for parameter expiry_time. 您不能为参数expiry_time传递字符串“ sysdate + 7”。

You could compose a datetime object or perhaps just change your procedure to accept a numeric "days offset" and add or subtract that from sysdate within the procedure itself. 您可以组成一个datetime对象,或者只是更改过程以接受数字“天偏移”,然后在过程本身内的sysdate中添加或减去它。

For the committing, you can call commit on cx_Oracle's connection object. 对于提交,您可以在cx_Oracle的连接对象上调用commit

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

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