Re: [cx-oracle-users] ValueError: string data too large
Brought to you by:
atuining
From: Mark H. <mh...@pi...> - 2010-07-07 22:45:09
|
On 7/7/10 3:39 PM, Anthony Tuininga wrote: > Hi Mark, > > This error can occur if you bind a string shorter than 4000 characters > in one iteration and then bind a string larger than 4000 characters in > another iteration. Or if you use setinputsizes() to specify a > character string and then try to bind more than 4000 characters. The > 4000 characters (bytes really) can be different if you use a multibyte > character set on the client/server, of course. If you pass a string > longer than 4000 characters on the first iteration then cx_Oracle will > use a "long" variable -- and Oracle has a number of restrictions on > those so I would use CLOB personally. > > You can use cursor.var() if you like, or you can simply use > setinputsizes() to specify that you want to use a CLOB in a particular > position and then simply pass the string directly. > > HTH, > Anthony Thanks Anthony, it does! > > On Wed, Jul 7, 2010 at 2:43 PM, Mark Harrison<mh...@pi...> wrote: >> A coworker has asked me this... he's occasionally geting a >> "ValueError: string data too large" when calling cursor.execute(). >> >> >> we're going to try something like this: >> >> clob = cursor.var(cx_Oracle.CLOB) >> clob.setvalue(0, contents) >> >> and see if that works. But I'm a bit confused, since the code >> below works the majority of the time. >> >> 1. are we on the right track to change to use clob.setvalue? >> >> 2. should the simple string code work at all? >> >> Many TIA!!! >> >> Mark >> >> ---------------------------- >> >> >> Mark, >> This is the "ValueError: string data too large" error message >> that I brought up in our last meeting. It only happens >> sometimes, but causes grief when it does. In this instance >> the value for the CLOB column called "contents" in our >> foo table is around 130,000 characters. >> There are other rows in that table with longer values up to >> 179507, so clearly the limit (if there is a limit at all) is >> not being exceeded. >> >> This one happened a little before 3:29 today. Could you ask >> the DBAs to look into this? >> >> >> 370 contents = simplejson.dumps(newworkspace).encode('ascii') >> 371 sql = "UPDATE foo SET name=:1, owner=:2, viewers=:3, contents=:4 WHERE workspaceid=:5" >> 372 values = [name, owner, viewers, contents, workspaceid] >> 373 self._cursor.execute(sql, values) >> >> >> >> > File "/data/foo.py", line 373, in saveWorkspace >> > self._cursor.execute(sql, values) >> > >> > ValueError: string data too large >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Sprint >> What will you do first with EVO, the first 4G phone? >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |