【问题标题】:Access LOB value with cx_Oracle and ORA-22922 error使用 cx_Oracle 和 ORA-22922 错误访问 LOB 值
【发布时间】:2013-08-13 18:40:38
【问题描述】:

我正在尝试访问由带有cx_Oracle 的过程返回的 LOB 的值。 LOB 是元组的第一个字段 ('reg[0]')。

当我这样做时:

regs = cursor.fetchall()
for reg in regs:
    print reg[0]

出现以下错误:

DatabaseError: ORA-22922: nonexistent LOB value

当我尝试使用 read() 方法时(reg[0].read() 而不是print reg[0]),但错误是一样的。

在这种情况下如何访问 LOB 值?

【问题讨论】:

  • The cx_Oracle documentation advises against using fetchall with LOBs。如果您写 for reg in cursor 而不是将所有数据读入列表然后打印出来,是否有帮助? (顺便说一句,我无法重现您的错误;我只能重现上面 cx_Oracle 链接中提到的错误。我使用的是 Oracle XE 11.2.0.2.0、Python 2.7.3 和 cx_Oracle 5.1.2,如果有帮助的话。)

标签: python oracle cx-oracle


【解决方案1】:

我使用的是 sqlalchemy Session 并直接在 Session 中而不是游标中执行命令。

当我创建一个游标并执行cursor.execute(procedure) 时,我可以根据需要使用 read() 方法访问 LOB 内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多