smaudet / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

Oracle and Decimal_cvt issue #46

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
OS: Microsoft 2008 R2

I'm trying to obtain data from Oracle to Microsoft SQL Server but having issues 
with decimal values.

Connection string:
Microsoft: con_string = "DSN=localhost;" 
Oracle: con_string = "DSN=SERVER;Uid=login;Pwd=pwd;"

When using Microsoft for Oracle ODBC, when reading a decimal value it returns 
an error.

for field in row:
   params.append(field)

To read the data I use a workaround to work:

temp = "{0}".format(field)
if temp == "None":
   temp = None
params.append(temp)

But if I'm using Oracle driver it returns an error in the "fetchall()"

Driver: Microsoft ODBC for ORACLE
('HY104', '[HY104] [Microsoft][ODBC SQL Server Driver]Invalid scale value')

                    try:
                        for row in cursor_source.fetchall():
                            params = []
                            for field in row:
                                #temp = "{0}".format(field)
                                #if temp == "None":
                                #    temp = None
                                #params.append(temp)
                                params.append(field)
                            try:
                                cursor.execute(temp_sql, params)
                                cursor.commit()
                            except pypyodbc.Error as e:
                                func_error = "{0}".format(e)
                                break
                    except pypyodbc.Error as e:
                        func_error = "{0}".format(e)

Driver: Oracle in OraClient11g
  for row in cursor_source.fetchall():
  File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 1819, in fetchall
  File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 1871, in fetchone
  File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 587, in Decimal_cvt
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

Original issue reported on code.google.com by portela....@gmail.com on 24 Jul 2014 at 9:57