[cx-oracle-users] Re: Inserting on table where is CLOB column
Brought to you by:
atuining
|
From: Jani T. <re...@lu...> - 2005-05-17 20:28:37
|
Anthony Tuininga kirjoitti:
> 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 column.
>>>>>>
>>>>>>It should be CLOB instead of LONG. Is there way to get around this problem?
>>>>>>
>>>>>>When value is less than 4000 chars inserts goes well, but after breaking
>>>>>>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 = cx_Oracle.Connection("user/pw@tns")
>>>>>cursor = connection.cursor()
>>>>>cursor.setinputsizes(value = cx_Oracle.CLOB)
>>>>>cursor.execute("insert into table values (:value)",
>>>>> value = "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().
>>
>>Well, they are, but I don't have control over them.. :)
>>
>>Since same call in code is used for different database backends (like
>>Postgres)
>
>
> Ah, I see. That does make life a little more difficult.
>
And now you tell me that..? :)
>>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.
Well fortunately (and currently) this is situation...
> 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.
Any pointers in web (example would be nice) since I'm just becoming
friend of Python and I might be trying to do things wrong here...
But this has helped me a bit...
--
Jani Tiainen
|