Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: insert clob into table

Re: insert clob into table

From: steve <steve_at_aol.com>
Date: Fri, 3 Mar 2006 12:17:43 +0800
Message-ID: <du8g1701a37@news3.newsguy.com>


On Thu, 2 Mar 2006 22:10:23 +0800, amogh wrote (in article <4406F9FF.7030305_at_gmail.com>):

> mwojtow wrote:

>> I have got table with many fields - including clob. And I would like to
>> put data using INSERT command from C++ using OCCI.
>> example below (not working :()
>>
>> Clob clob(conn); //existing connection object
>> string s("looooong string"); // assume that this string is 8k long
>> int s_size=s.length();
>> clob.setEmpty();
>> string sql="INSERT INTO tbl (string_col, clob_col) VALUES (:1,:2)";
>> stmt->setSQL(sql);
>> stmt->setString(1,"aaaa");
>> clob.write(s_size,(unsigned char *)s.c_str(),s_size);
>> stmt->setClob(2,clob);
>> stmt->executeUpdate();
>>
>> And this is not working.I get error
>> ORA-22275: invalid LOB locator specified
>>> (

>> If I changed lines
>>
>> clob.write(s_size,(unsigned char *)s.c_str(),s_size);
>> stmt->setClob(2,clob);
>>
>> to
>>
>> stmt->setString(2,s);
>>
>> clob field has only part of string s value :(
>>
>> primary key is timestamp field and is set to default TIMESTAMP_NOW so I
>> cannot get it's value :(
>>
>> database is on another server then client I run so I prefer not to set
>> primary key to client local timestamp which can be different from server
>> one.
>> I'm using Oracle 9i database and client.
>> Please help!
> 
> You will have to first insert an empty clob. SELECT the clob
> descriptor column and then UPDATE the clob. Take a look at the 
> occiclob.cpp sample here:
> 
> 

http://www.oracle.com/technology/sample_code/tech/occi/files/occi10gsamples.ta
> r.gz
> 
> Rgds.
> Amogh

the way i do it , is when i define the table, set the "default value" to empty_clob()

that sets it up automatically.
then you can just stuff your text in. Received on Thu Mar 02 2006 - 22:17:43 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US