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: HELP>...Very Simple Question about Pro*C

Re: HELP>...Very Simple Question about Pro*C

From: Ed Prochak <prochak_at_my-dejanews.com>
Date: Fri, 26 Mar 1999 15:29:39 GMT
Message-ID: <7dg94l$s94$1@nnrp1.dejanews.com>


In article <36FAD5F5.CAE37961_at_gwl.com>,   Dogan Cibiceli <dcib_at_gwl.com> wrote:
> To ALLPROC's
> I am wondering what implications could there be if a column of a
> table is VARCHAR2(13) length and I insert into this column a VARCHAR of
> length 15 (Pro*C variable). It should have been 14 including the null

NO NO NO! Don't include the null. VARCHAR is a counted string, It doesn't require a null terminator on INSERT. It doen't get a null terminator on FETCH.

 Sorry, but I've had to fix too many broken ProC programs due to lack of understanding by the original programmers on the difference between Oracle VARCHAR and C strings. Inserting a nul terminator in the middle of a VARCHAR is a good way to really confuse things.

(sqlplus shows "ABDEF", but the ProC program prints "AB" and Access shows "AB". The real data is 'AB<nul>DEF', ie length 6.)

> but it is 15. What could go wrong ? Does Pro*C differ in the way it
> handles this situation from V6 to V7 ?
>
> Dogan
>
>

Does Oracle return an error or does it truncate if the data is too big for the column? I'm not sure and I'm not near my manuals. I've not worked with V6 at all so can't answer about it's differences from V7.

Other things to consider: Is the varchar(15) blank padded? you could RTRIM() it. Did you FETCH this from some other table. You could always simply truncate it to length 13.

Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3702

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Mar 26 1999 - 09:29:39 CST

Original text of this message

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