[DB-SIG] Re: Returning floats in DCOracle2
Mon, 16 Dec 2002 20:08:37 +0500
Yes, you are right. The matter was in the decimal separator. Setting it
manually to "." resolves the problem. Thank you for the help.
bash-2.04$ cat test.py
db = DCOracle2.connect("x/y@z")
c = db.cursor()
c.execute("ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '")
c.execute("SELECT 0.5 FROM DUAL")
bash-2.04$ python test.py
Matthew T. Kromer wrote:
> The problem may have to do with a mismatch between the C locale's=20
> sscanf() function for parsing numbers, and Oracle's numeric formatting=20
> environment setting. This might come from the difference between trying=20
> to parse "0.5" using "," as the decimal separator or vice versa ("0,5"=20
> with ".").
> The reason DCOracle2's C layer handles numbers as strings is old, and no=20
> longer valid (it used to cause problems under Linux to initialize in=20
> Object mode). At some point in time I'll rip out all of the string /=20
> number conversion (which usses sscanf()) and replace it with various=20
> OCINumber calls.
> Alternatively, there might be a compiler problem.
> I was unable to reproduce the problem myself.
> jno wrote:
>>could not reproduce:
>>[jno@hypnos jno]$ python =20
>>Python 2.1.3 (#2, Jul 24 2002, 11:13:04) [C] on hp-uxB
>>Type "copyright", "credits" or "license" for more information.
>>>>>d =3D DCOracle.Connect('xxx/xxx@xxx')
>>>>>c =3D d.cursor()
>>>>>c.execute('select 0.5 from dual')
>>[jno@hypnos jno]$ uname -a
>>HP-UX hypnos B.11.00 U 9000/800 654339382 unlimited-user license
>>well, it is NOT DCO2, Py 2.2.2 and HP-UX 11.11 ;-)
>>=F7 =F0=D4=CE, 29.11.2002, =D7 12:57, Alexei Ustyuzhaninov =CE=C1=D0=C9=D3=
>>>I have ran into a silly problem with DCOracle2. It returns wrong float=20
>>>numbers from SELECT statement.
>>>bash-2.04$ cat test.py
>>>db =3D DCOracle2.connect("x/y@z")
>>>c =3D db.cursor()
>>>c.execute("SELECT 0.5 FROM DUAL")
>>>bash-2.04$ python test.py
>>>Unfortunately 0.5 is somewhat different from 3.6097722056218853.
>>>The environment is:
>>>Could somebody give me a tip on the problem please?