Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

insert clob into table

245 views
Skip to first unread message

mwojtow

unread,
Mar 1, 2006, 9:47:29 AM3/1/06
to
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!

amogh

unread,
Mar 2, 2006, 8:58:23 AM3/2/06
to

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.tar.gz

Rgds.
Amogh

steve

unread,
Mar 2, 2006, 11:17:43 PM3/2/06
to
On Thu, 2 Mar 2006 22:10:23 +0800, amogh wrote
(in article <4406F9FF...@gmail.com>):

> 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.


mwojtow

unread,
Mar 3, 2006, 10:13:30 AM3/3/06
to
the problem exists if you cannot identify record you have just inserted.
my primary key is set automaticaly on server. after inserting I'm not
sure if somene else has not set another record into table so I cannot
just take the last record. and combination of fields is not unique!
but I solved it:)
I used setString on clob column and it seems to work:) thanks everyone
for advices.

steve

unread,
Mar 8, 2006, 6:04:55 PM3/8/06
to
On Fri, 3 Mar 2006 23:13:30 +0800, mwojtow wrote
(in article <du9meq$sfo$1...@kujawiak.man.lodz.pl>):

steve

unread,
Mar 8, 2006, 6:06:43 PM3/8/06
to
On Fri, 3 Mar 2006 23:13:30 +0800, mwojtow wrote
(in article <du9meq$sfo$1...@kujawiak.man.lodz.pl>):

> steve <st...@aol.com> wrote:

cannot identify records you just inserted?

use the "returning" clause for the sql statement & return a key that
identifies the record.

but that said , you better be setting your clob to Empty_clob() , before
putting anything into it or yuo will run into problems later.


0 new messages