waliwali / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Exception when fetching DECIMAL with comma as the decimal point #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1.
 -- My DB2® subsystem is tailored to use a comma as the decimal point.

 CREATE TABLE TMP.DECIMAL_TEST
 (  FLD    DECIMAL(8, 1)  );

 INSERT INTO TMP.DECIMAL_TEST
 VALUES 12.34;

2.
 import ibm_db_dbi as db

 con = db.connect('DSN=nsi23')
 cur = con.cursor()
 cur.execute('select fld from tmp.decimal_test ')
 print cur.fetchall()

What is the expected output? 

[[12.34],]

What do you see instead?

Traceback (most recent call last):
  File "tst.py", line 6, in <module>
    print cur.fetchall()
  File
"c:\python25\lib\site-packages\ibm_db-0.2.9-py2.5-win32.egg\ibm_db_dbi.py",
line 1134, in fetchall
    return self._fetch_helper()
  File
"c:\python25\lib\site-packages\ibm_db-0.2.9-py2.5-win32.egg\ibm_db_dbi.py",
line 1095, in _fetch_helper
    row_list.append(self._fix_return_data_type(row))
  File
"c:\python25\lib\site-packages\ibm_db-0.2.9-py2.5-win32.egg\ibm_db_dbi.py",
line 1205, in _fix_return_data_type
    raise DataError("Data type format error: "+ str(inst))
ibm_db_dbi.DataError: ibm_db_dbi::DataError: Data type format error:
Invalid literal for Decimal: '12,34'

What version of the product are you using? On what operating system?
ibm_db-0.2.9-py2.5-win32.egg
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32 Windows XP sp2 v.5.1.2600
DB2 client v9.5.0.808
DB2 server v8.1.16.429 @ Windows 2003

Original issue reported on code.google.com by D.V.Selitsky@gmail.com on 8 May 2008 at 3:21

GoogleCodeExporter commented 9 years ago
Hi,
    Please edit the db2cli.ini file (usually found C:\Program Files\IBM\SQLLIB) and 
add the following line in the section pertaining to your database -
Patch2=15

e.g. - 

[ABC]
DATABASE=xyz
Patch2=15

    This will force CLI to use a period separator instead of the default locale's 
decimal separator in character output. This will solve the problem. Please feel 
free 
to contact us for further assistance. 

Original comment by abhigyan...@in.ibm.com on 14 May 2008 at 10:45

GoogleCodeExporter commented 9 years ago
Thanks, this helped.

JFYI,
patch2=15 applied on client side through `ODBC Data Source Administrator`, later
db2cli.ini found in "c:\Documents and Settings\All Users.WINXP\Application
Data\IBM\DB2\DB2COPY1\"

Original comment by D.V.Selitsky@gmail.com on 14 May 2008 at 11:22

GoogleCodeExporter commented 9 years ago

Original comment by abhigyan...@in.ibm.com on 14 May 2008 at 11:47

GoogleCodeExporter commented 9 years ago
I am using Windows 7 sp2 and db2 connect V10.2 and I am not using a data source 
to connect (and  there is no db2cli.ini file in my User directory). Instead I 
use the full connection  string ('DRIVER={IBM DB2 ODBC 
DRIVER},PROTOCOL=TCPIP,... etc) . where can I  put this 'Patch=15' information 
in the above environment?

Original comment by zisisk...@gmail.com on 6 May 2013 at 6:59

GoogleCodeExporter commented 9 years ago
If you are using DB2 connect product then you should have db2cli.ini file. you 
can check CLI cfg by following command in DB2CMD command prompt
>db2 get cli cfg

and update the CLI cfg to add patch2=15 on all the databases by using following 
command
>db2 update cli cfg for section COMMON using Patch2 15

Thanks,
Rahul

Original comment by rahul.pr...@in.ibm.com on 7 May 2013 at 5:38