Tell me, please, how to read the clobber correctly from the table?

Cur.execute("select email, html, id from table") lettter = cur.fetchall() conn.close() for i in letter: if len(letter) > 0: rec = i[0] html = i[1].read() #Это CLOB id = i[2] 

Then I start to sort out and get an error.

 Cx.oracle.programmingerror: lob variable no longer valid after subsequent fetch 

Everything works if you use the fetchone () method, but then you have to dynamically collect the SQL query and pass it the line number. How to be?

  • You can bring the code where you directly read CLOB's and where you close the cursor and / or connection - MaxU
  • MaxU, corrected the code above. connection closed both at the end of the whole code, and after fetch. Cursor did not close at all - ss_beer

1 answer 1

The documentation explicitly states not to use fetchall() in the event that you have a CLOB:

Internally, Oracle uses LOB locators. Thus, it is important that the internal object fetch takes place.

The cursor is an iterator. In particular, do not use the fetchall () method. The LOB variable is not defined.

Try this:

 cur.execute("select email, html, id from table") for row in cur: ...