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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: oracle Pro C question

Re: oracle Pro C question

From: Jeff Herrick <jherrick_at_host.ott.igs.net>
Date: Mon, 4 Sep 2000 13:23:05 -0400 (EDT)
Message-Id: <10609.116165@fatcity.com>


I would say you should 'piss' all over your CHAR variable datatype if you want the real answer. =8-)

declare it as

   VARCHAR2 field(200);

The VARCHAR2 macro is defined in the default PRO*C headers as a struct such that after the fetch you can reference the field.len and field.arr member variables for the length and pointer to the data respectively

Also field.len is the index of the NULL...ie the character length. You will eventually get into the habit of doing

field.arr[field.len] = '\0';

after a fetch to guarantee the NULL is in the right place =8-/

Cheers

Jeff Herrick
Jeff Herrick & Associates

On Mon, 4 Sep 2000, John Dunn wrote:

>
>
> > -----Original Message-----
> > From: Jamie Pearce
> > Sent: 01 September 2000 17:25
> > To: John Dunn
> > Subject: oracle question
> >
> > Can you post this piss easy question to your Oracle group - I've wasted
> > too much time trying to do it.
> >
> > I have an Oracle field on a table defined as VARCHAR2(200) and a C host
> > variable defined as char mystring[200].
> >
> > How do I select the oracle field in to the C host variable so that a null
> > character automatically gets appended to the string?
> > e.g. if the Oracle field contained "hello" then the C host variable would
> > contain "hello\0" with no extra blanks?
Received on Mon Sep 04 2000 - 12:23:05 CDT

Original text of this message

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