chornbeak / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Teradata - INT columns being returned as 0 instead of value on python27 #389

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Connect to Teradata system
2. Query for INT columns
3.

What is the expected output? What do you see instead?
I expect to see values other than 0

What version of the product are you using? On what operating system?
pyodbc 3.0.7
python 2.7
CentOS release 5.11

Please provide any additional information below.

If in my query I CAST the INT as BIGINT it works.

Here is my sample code
import os
import pyodbc
pyodbc.pooling = False
os.environ['ODBCINI'] = '/etc/odbc.ini'

tdConn = pyodbc.connect(dsn='td_app', uid='dse', pwd='*******', autocommit=True)

cursor = tdConn.cursor()
#stmt = "sel top 10 seg_batch_sk, cast(size_cnt as bigint) from seg_batch_f 
where size_cnt > 0"
stmt = "sel top 10 seg_batch_sk, size_cnt from seg_batch_f where size_cnt > 0"

cursor.execute(stmt)

res = [row for row in cursor.fetchall()]

cursor.close()

print res

Here are the results

Not CAST
[(2374169535L, 0), (2379981746L, 0), (311410040985L, 0), (321391475642L, 0), 
(311407867327L, 0), (311399737858L, 0), (2371418520L, 0), (321390910439L, 0), 
(2372278387L, 0), (2381445989L, 0)]

CAST
[(311396260175L, 15363L), (2381968201L, 10801L), (311416800519L, 7L), 
(2377688627L, 1875L), (2386825559L, 265L), (2377429912L, 21L), (311411011289L, 
84L), (311413161989L, 6095L), (321413509615L, 13L), (2380870629L, 196L)]

Original issue reported on code.google.com by samah.so...@gmail.com on 9 Jan 2015 at 10:35