Re: Help with Pro C dynamic method 4

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1998/01/08
Message-ID: <34bb3ebe.25567984_at_inet16>#1/1


There really aren't any floats or integers in Oracle. There are numbers... Numbers are the datatype that hold 38 digits of precision, a decimal place and a sign. I would recommend when using dynamic sql method 4, you select everything into a string -- numbers, dates, strings -- all of them into a string.

If you select a number into an int/long it loses the decimals as you have seen.

If you select a number into a double/float you'll loose precision. 22.22/11.22 for example is approximately 1.98039. If you select it into a string you'll see it is more precisely:

  1* select to_char(22.22/11.22) from dual SQL> / TO_CHAR(22.22/11.22)



1.98039215686274509803921568627450980392

So in method 4 you will either select into a double or you will select into a long for numbers -- you can't tell the difference really, to Oracle they are just numbers, Oracle is getting the right datatype "number", you are picking the wrong datatype to put it into "int". Or, more flexibly, you will select it into a character string and atof() or atoi() when and if it really needs to be a number....

On Wed, 07 Jan 1998 17:47:24 -0800, Joseph <gollapal_at_brcsun0.tamu.edu> wrote:

>I am running Oracle 7.3.2 on Solaris 2.5 and Pro C 2.2
>
>I am trying to use the dynamic method 4 to get data from oracle tables.
>Everthing works fine but if I use and expression in the select
>statements
>it does not get the correct datatypes.
>Example if one is number(5,2) and its value is 22.22
> and two is number(5,2) and its value is 11.22
>
>and I execute the statement using this select using sample10.pc
> select one/two from table test;
>
>will give an integer 1 while on an SQL statement will give the result
>1.98039
>which is the correct answer for 22.22/11.22 = 1.98039
>
>I checked the variable T[i] which is the value of the datatype of the
>select
>statement it is always set to an integer (which is 3) even though one
>and two are
>both floats. Is there a way to get around this?
>
>In short I want to use the dynamic method 4 and include an expression in
>the
>select statement that will result in a float. Currently I get an
>integer?
>Please e-mail me at gollapal_at_brcsun0.tamu.edu.
>Thanks in advance
>Joseph Gollapalli
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Jan 08 1998 - 00:00:00 CET

Original text of this message