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

How can I read/write a CLOB using Pro*C ?

399 views
Skip to first unread message

Peter Dickmann

unread,
Jun 9, 2000, 3:00:00 AM6/9/00
to
Hi,

I managed to read/write a CLOB by specifying:

OCIClobLocator *locator;
varchar *data;
data = (varchar *) malloc( 2 + size );
data->len = (short)size;
strcpy( data->arr, my_data );
EXEC SQL LOB WRITE ONE :size FROM :data INTO :locator;

But, the varchar isn't sufficient to hold my_data, hence I tried to use LONG
VARCHAR, here the len field is an integer rather than a short. But the
declaration:

long varchar *data;

is illegal; what's missing?

Thanx, Peter


Thomas J. Kyte

unread,
Jun 9, 2000, 3:00:00 AM6/9/00
to
In article <3940...@news.lhsgroup.com>,

see sample4.pc

it'll be along the lines of:

/* This is the definition of the long varraw structure.
* Note that the first field, len, is a long instead
* of a short. This is becuase the first 4
* bytes contain the length, not the first 2 bytes.
*/
typedef struct long_varraw {
ub4 len;
text buf[1];
} long_varraw;


/* Type Equivalence long_varraw to LONG VARRAW.
* All variables of type long_varraw from this point
* on in the file will have external type 95 (LONG VARRAW)
* associated with them.
*/
EXEC SQL TYPE long_varraw IS LONG VARRAW REFERENCE;

and then you'll use the type long_varraw. (or long_varchar -- changing
the LONG VARRAW into LONG VARCHAR)

--
Thomas Kyte (tk...@us.oracle.com) Oracle Service Industries
Howtos and such: http://osi.oracle.com/~tkyte/index.html
Oracle Magazine: http://www.oracle.com/oramag
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages