`
desert3
  • 浏览: 2139702 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

LOB variable no longer valid after subsequent fetch

阅读更多
cx_oracle读取oracle wm_concate函数操作过后的长文本clob字段,当使用fetchall或者fetchmany读取数据时,报上面的错

参考下面的文档,发现只能使用下面2种方式中的任一种来操作数据,总体来说,大数据量时读取效率不高。
通过to_char(wm_concat(brand_name))把clob字段变成varchar字段后,再采用cursorSelect.fetchmany(1000),对于30W条数据的处理时间从10分钟减少到1分半!

for result in cursorSelect:
尝试了几次感觉效率比下面的稍微好点
或者
result = cursorSelect.fetchone() 自己控制while循环读取


参考Lob objects
Internally, Oracle uses LOB locators which are allocated based on the cursor array size. Thus, it is important that the data in the LOB object be manipulated before another internal fetch takes place. The safest way to do this is to use the cursor as an iterator. In particular, do not use the fetchall() method. The exception “LOB variable no longer valid after subsequent fetch” will be raised if an attempt to access a LOB variable after a subsequent fetch is detected.
分享到:
评论
1 楼 loot00 2016-10-13  
您好!
  我也遇到了相同的错误信息。我是用f_link_lob()做聚合,读取几条数据时很正常,读取几万条数据就会报这个错。
  没看清楚您的解决方法,是要把代码改成这样的吗?
    for result in cursorSelect:
        result = cursorSelect.fetchone()
尝试着这样做了以后,结果返回了一条记录的第一个字段。于是把fetchone()改为fetchmany(1)。结果只能返回一条记录。现在也不知道怎么能改成功了。
  希望您能帮忙解答我的问题,谢谢!

相关推荐

Global site tag (gtag.js) - Google Analytics