Re: [cx-oracle-users] Re: Inserting on table where is CLOB column
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2005-05-17 19:53:22
|
On 5/17/05, Jani Tiainen <re...@lu...> wrote: > Anthony Tuininga kirjoitti: > > On 5/17/05, Jani Tiainen <re...@lu...> wrote: > > > >>Charl P. Botha kirjoitti: > >> > >>>On 5/17/05, Jani Tiainen <re...@lu...> wrote: > >>> > >>> > >>>>When I'm trying to insert long text in CLOB column I get error > >>>>ORA-01461. Something like LONG value can be only to be bind in LONG c= olumn. > >>>> > >>>>It should be CLOB instead of LONG. Is there way to get around this pr= oblem? > >>>> > >>>>When value is less than 4000 chars inserts goes well, but after break= ing > >>>>barrier problem occurs. > >>>> > >>>>Using cx_Oracle 4.1 with Python 2.3, Windows XP, Oracle 10g > >>> > >>> > >>>It looks like you have to use bind variables. This is from an example > >>>Anthony posted on this list to answer one of my questions: > >>> > >>>connection =3D cx_Oracle.Connection("user/pw@tns") > >>>cursor =3D connection.cursor() > >>>cursor.setinputsizes(value =3D cx_Oracle.CLOB) > >>>cursor.execute("insert into table values (:value)", > >>> value =3D "A very long string") > >> > >>Didn't saw that in list. It would solve my problem if I knew queries > >>before, but... > >> > >>Problem is that I haven't got control over bindings since code is > >>basically just code below: > >> > >>def runquery(cursor, query, args): > >> return cursor.execute(query, args) > > > > > > The args __are__ the bind variables so you definitely have control. > > You simply have to make sure you call cursor.setinputsizes() before > > calling runquery(). >=20 > Well, they are, but I don't have control over them.. :) >=20 > Since same call in code is used for different database backends (like > Postgres) Ah, I see. That does make life a little more difficult. > This is somewhat possible to fix in current situation since I know that > strings that are > 4k must be clobs... Not necessarily in general but that could be true in your application. You also have long, long raw and BLOB to deal with. If your application doesn't use them you can make this assumption. BTW, if you __really__ have no control, you can always subclass Connection and Cursor and do whatever you need to do. Subclassing has been quite convenient and I use it myself for a number of situations where the code is used by multiple database adapters. > -- >=20 > Jani Tiainen >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=3D7412&alloc_id=3D16344&op=3Dclick > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |