Re: Pro*C - extra space after variables

From: Kenneth C Stahl <BlueSax_at_Unforgettable.com>
Date: Tue, 07 Dec 1999 13:26:25 -0500
Message-ID: <384D5151.E2276D39_at_Unforgettable.com>


Clint Eastwood wrote:
>
> HiYa
>
> wow ... getting some milage today ... :-)
>
> I am finding that if I do something like this:
>
> EXEC SQL SELECT to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
> INTO :order_details_rec->p_element->order_place_date_time
> FROM dual;
>
> that the output of a printf on the item is: IE
>
> printf("--%s-- is the date\n",
> order_details_rec->p_element->order_place_date_time);
>
> --07-DEC-1999 16:57:06 -- is the date
>
> where is the extra space coming from?? I've even tried to rtrim it, and
> it still has the spaces...
>
> thanks
>
> Ohhh Pro*C/C++: Release 2.2.3.0.0
>
> thanks :-)
>
> See Ya
> (when the bandwidth gets better ;-)
> Chris Eastwood Please remove undies for reply
> Photographer, Stunt Programmer
> Motorcyclist and dingbat

I'm betting that your host variable is a char rather than a varchar and that it more than 21 bytes long. In situations like that Oracle does the best that it can, but sometimes it isn't what you'd like. There are a couple things you can do. Switch to use a varchar instead of a char array. Or, use an indicator variable and use it to see the null terminator in the host variable.

I'll also lend you a bit of my experience. I've been writing PRO-C for many years now and I never, ever write implicit cursors for SELECTS. Never! Ever! They are always potential trouble spots and no one has ever demonstrated to me an ironclad reason for using one over using a OPEN/FETCH/CLOSE sequence.

..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
..................................................................
Received on Tue Dec 07 1999 - 19:26:25 CET

Original text of this message