Forum Stats

  • 3,735,088 Users
  • 2,247,101 Discussions


Inserting a CLOB using cx_Oracle

976212 Member Posts: 1
edited Nov 27, 2012 3:03AM in Python
I outlined the question here, however for continuities sake I'll re-post the question here.

I am trying to insert a CLOB using the following code.

cursor = connection.cursor()
cursor.setinputsizes(HERP = cx_Oracle.CLOB)

cursor.execute("INSERT INTO myTable (FOO, BAR) VALUES (:FOO, :BAR)", FOO=val1, BAR=val2)
cursor.execute("INSERT INTO myTable2 (HERP) VALUES (:HERP)", HERP=val3)
#len(HERP) 39097

When I run the script WITHOUT cursor.setinputsizes(HERP = cx_Oracle.CLOB) it fails on the second query WITH ValueError: string data too large, when I run the script with cursor.setinputsizes(HERP = cx_Oracle.CLOB) it fails on the first query with DatabaseError: ORA-01036: illegal variable name/number. The CLOB I am trying to insert contains a code snippet (i.e. it has a lot of semi colons, commas and parenthesis), *"string".decode("ascii")* returns u'string', so unicode isn't the problem... right? I don't know if either of these things are problems. The field in the database is a currently a CLOB, however I have tried it with an NCLOB and the behavior did not change.

I've been going through the discussions on the cx-oracle-users (specifically ) list, but no luck yet.

How can I use cx_Oracle to insert a CLOB into an Oracle database?


This discussion has been closed.