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: Pro*C VARCHAR unsigned char Problem

Re: Pro*C VARCHAR unsigned char Problem

From: AWILSON <awilson_at_rci.rogers.com>
Date: 1997/01/21
Message-ID: <32E52C36.4768@rci.rogers.com>#1/1

Phil wrote:
>
> VARCHAR is actually a struct that contains
> an unsigned char, but I'd rather not have to explicitly type cast each of
> these calls to (char *). Is there an easy
> way around this?
>
> Phil
> philr_at_ibm.net

Aha.. if you're going to use VARCHARs then you should have created a macro to do the job - something like

#define STRTOVAR(x,y) {strcpy(x.arr,y); x.len = strlen(x.arr)}

you can also do one for VARTOSTR and one for VARTOVAR then all you have to code is

        STRTOVAR(array_variable_name, string_variable_name);

makes the code more legible, and you make less mistakes that way. Then, when
the rules change, you just have to amend the macro to '(char *)x.arr'. Also
if you're really smart you can add bounds checking to make sure you don't blow
any string array lengths (aaagh - core dump). Take the plunge now and convert your code!

My thanks go to Dave Edwards at EMC2 in the UK for that brilliant tip. Another lesson painfully learned.



The above reflect my personal views and in no way are connected with whomsoever I may be working for at this particular point in time.  
Alan Wilson                              Help fight continental drift.
======================================================================
Received on Tue Jan 21 1997 - 00:00:00 CST

Original text of this message

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