cx_Oracle和输出变量 [英] cx_Oracle and output variables

查看:366
本文介绍了cx_Oracle和输出变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试再次使用Oracle 10数据库:

I'm trying to do this again an Oracle 10 database:

cursor = connection.cursor()
lOutput = cursor.var(cx_Oracle.STRING)
cursor.execute("""
            BEGIN
                %(out)s := 'N';
            END;""",
            {'out' : lOutput})
print lOutput.value

但是我得到了

DatabaseError: ORA-01036: illegal variable name/number

是否可以通过这种方式在cx_Oracle中定义PL/SQL块?

Is it possible to define PL/SQL blocks in cx_Oracle this way?

推荐答案

是的,您可以执行匿名PL/SQL块.您的输出参数的绑定变量的格式不正确.它应该是:out而不是%(out)s

Yes, you can do anonymous PL/SQL blocks. Your bind variable for the output parameter is not in the correct format. It should be :out instead of %(out)s

cursor = connection.cursor()
lOutput = cursor.var(cx_Oracle.STRING)
cursor.execute("""
            BEGIN
                :out := 'N';
            END;""",
            {'out' : lOutput})
print lOutput

哪个产生输出:

<cx_Oracle.STRING with value 'N'>

这篇关于cx_Oracle和输出变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆