Stack Overflow解决方案:
cx_Oracle版本问题,在cx_Oracle5版本上有部分限制,在cx_Oracle6版本上没有此项限制。
This is a limitation of versions of cx_Oracle 5 and earlier. The new version (cx_Oracle 6) doesn't have this limitation. You can upgrade using this command:
python -m pip install cx_Oracle --upgrade
更新完成之后,程序运行通过。
原因分析:
cx_oracle读取oracle wm_concate函数操作过后的长文本clob字段,当使用fetchall或者fetchmany读取数据时,报上面的错
In cx_Oracle 5 and earlier the LOB locators were stored in the array used for fetching; so each round trip to the database would overwrite the LOB locators from the previous fetch. In cx_Oracle 6, the LOB locators are associated with the LOBs themselves.
加入此项限制的原因:
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.