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: Length of VARCHAR2 fields

Re: Length of VARCHAR2 fields

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/10/23
Message-ID: <34547384.95809817@newshost>#1/1

Use the datatype '5' (string) in the sqlda structure when you fill it in before the fetch. For example:

   for (i = 0; i < select_dp->F; i++)
    {

        sqlnul (&(select_dp->T[i]), &(select_dp->T[i]), &null_ok);  

        select_dp->L[i] = /* Compute your max length + 1 here */
        select_dp->T[i] = 5;
        select_dp->V[i] = (char *)malloc( select_dp->L[i] );
    }

will fetch all variables out as null terminated strings instead of CHARS which are blank padded.....

On Thu, 23 Oct 97 09:20:14, Zekl <hz_at_tonbeller.com> wrote:

>
>Hello,
>
>I have an apllication in C reading data from Oracle tables. The program has
>been compiled using the Oracle precompiler Pro*C. The Programm uses dynamical
>SQL. Values are fetched using a SQLDA structure. My problem is to get the
>actual lenghth of VARCHAR2 data duroing FETCH. Before FETCH I store the
>maximum lenght of the data in the length element of the SQLDA. If I read a
>value which is shorter than this value Oracle always fills the buffer with
>padding blanks. The length element in the SQLDA remains unchanged.
>
>Does anyone know a solution for this problem ?
>
>Thank you
>
>Dr. Hans Zekl
>Ton Beller GmbH
>Email: hz_at_tonbeller.com
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

NOTICE: In order to cut down on the amount of time I spend applying silly logic to email addresses like "In order to cut down on spam, remove THIS from my email" or "In order to cut down on spam, reverse my email address", etc, I will simply hit delete when that mail bounces back to me, which is what I do with spam myself.  

I haven't figured out whats more time consuming for me, deleting spam or resending emails after re-reading the whole thing to figure out the algorithm to apply. Received on Thu Oct 23 1997 - 00:00:00 CDT

Original text of this message

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