Re: Conversion Problem in Pro*C advice needed
Date: Fri, 07 May 1999 12:57:49 -0600
Message-ID: <373337AD.E269ACBF_at_gwl.com>
Hi Alexander,
I am a bit wrong. There is a program written before me and it was
putting a double value ( not a float my mistake, late at night, posted the
prev. msg) into a number(17,2) database column. It was updating it. My
problem is during this update, it's certain that it will not be able to
store the precision since it holds two digits after decimal. I would
assume oracle would truncate or round the value when inserting into the
database column. My guess is it will be rounding.
The second question is I have to use that double variable to store in a varchar. This varchar value was actually the value stored from the database column number(17,2). Don't ask me why this is so. But it was done that way. So I would use sprinf(string,"%.2f",float) to store it in varchar. This varchar value would then be used later in that program. Therefore, I was worried it this conversion could affect the value in some way.
I know it is not a good explanation but it is complicated. See there is a number(17,2) column stored in varchar. Then converted into double and changed in the end. But no update on varchar has been made. So I would have to update this varchar value using the double I have got. I am thinking of using sprintf and wondering if there could be any problems with this approach. Because people already updated the table with the double value. I have to update varchar var using the double. I donot know whether this makes any sense. I could update the varchar by populating it using a query. But database access is something I would like to avoid because of its speed.
Dogan
"Alexander I. Doroshko" wrote:
> You mustn't use float variables for such precision, only double.
> Moreover, even double doesn't guarantee the 17th digit.
> If your really need all the 17 digits, use only char variables and make
> all your arithmetic in embedded sql statements.
> --
> Alexander I.Doroshko, aid_at_grant.kharkov.ua
> * Bank "Grant", Kharkov, Ukraine
> Dogan Cibiceli <dcib_at_gwl.com> wrote in article
> <37320E3F.9D28DD92_at_gwl.com>...
> : I have a question dealing with Pro*C and Oracle. Suppose I update a
> : database column whose type is number(17,2) with a float value in
> Pro*C.
> : How is the float value converted into number ? Rounded, truncated ??
> : Also if I use my sprintf function to change float into a char string
> : like sprintf(string,"%.2d",float) with 2 digit precision after the
> : point. And Suppose I use this char* value. How much of a difference
> can
> : I expect ? Does string always reflect correctly what's stored in
> : number(17,2) column? Thanks in advance
Received on Fri May 07 1999 - 20:57:49 CEST