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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How can I read/write a CLOB using Pro*C ?

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

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/06/09
Message-ID: <8hrt5d$nh1$1@nnrp1.deja.com>#1/1

In article <3940f633_at_news.lhsgroup.com>,   "Peter Dickmann" <pdickmann_at_de.lhsgroup.com> wrote:
> 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
>
>

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 (tkyte_at_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.
Received on Fri Jun 09 2000 - 00:00:00 CDT

Original text of this message

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