Re: Pro*C - extra space after variables

From: Clint Eastwood <cjundieseastwd_at_powerup.com.au>
Date: Wed, 08 Dec 1999 00:55:57 GMT
Message-ID: <82k9vi$1ad15_at_inetbws1.citec.com.au>


HiYa

[Quoted] [Quoted] You are bang on with the length of the char[] that I'm selecting into.

thanks for the advice. I certainly can see why implicict cursors could cause hassles, especially if there was more than one row brought back when you were expexting only one. however when getting something from dual, is it worth declaring a cursor and then opening/fetching/closing?

thanks for the suggestion about the indicator variable

I have been having difficulty with using varchar (I am still learning) in the host side systems.

In article <384D5151.E2276D39_at_Unforgettable.com>, Kenneth C Stahl <BlueSax_at_Unforgettable.com> wrote:
>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.
>
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................
>...................................................................

See Ya
(when the bandwidth gets better ;-)

Chris Eastwood                            Please remove undies for reply
Photographer, Stunt Programmer
Motorcyclist and dingbat Received on Wed Dec 08 1999 - 01:55:57 CET

Original text of this message