title: How do I solve the ORA-01704: string literal too long error in Python cx_oracle?
body: <p>I am trying to update an entry in a table usinig Python cx_oracle. The column is named "template" and it has a data type of CLOB.</p>
  
  <p>This is my code:</p>
  
  <pre><code>dsn = cx_Oracle.makedsn(hostname, port, sid)
  orcl = cx_Oracle.connect(username + '/' + password + '@' + dsn)
  curs = orcl.cursor()
  sql = "update mytable set template='" + template + "' where id='6';"
  curs.execute(sql)
  orcl.close()
  </code></pre>
  
  <p>When I do this, I get an error saying the string literal too long. The template variable contains about 26000 characters. How do I solve this?</p>
  
  <p>Edit:</p>
  
  <p>I found this: <a href="http://osdir.com/ml/python.db.cx-oracle/2005-04/msg00003.html" rel="nofollow">http://osdir.com/ml/python.db.cx-oracle/2005-04/msg00003.html</a><br>
  So I tried this:</p>
  
  <pre><code>curs.setinputsizes(value = cx_Oracle.CLOB)
  sql = "update mytable set template='values(:value)' where id='6';"
  curs.execute(sql, value = template)
  </code></pre>
  
  <p>and I get a "ORA-01036: illegal variable name/number error"</p>
  
  <p>Edit2:</p>
  
  <p>So this is my code now:</p>
  
  <pre><code>    curs.setinputsizes(template = cx_Oracle.CLOB)
      sql = "update mytable set template= :template where id='6';"
      print sql, template
      curs.execute(sql, template=template)
  </code></pre>
  
  <p>I get an ORA-00911: invalid character error now.</p>