Datetime field overflow

Izzet Ergas <[email protected]> Wed, 25 Aug 2010 10:26:07 -0400
Newsgroups gmane.comp.python.egenix.user
Message-ID <18A0150F50930146A769E0211F1C1BDC1561D4DC5A@FTLPMAILBOX03.citrite.net>
I'm getting this error when querying a MS SQL Server 2005 instance with the SQL Native client using mxODBC 3.0.4.

Error: 22008, 0, [Microsoft][SQL Native Client]Datetime field overflow, 7748

I don't always get the error, it only seems to happen for some values passed to the query. I think it is somehow related to the fact that a mx.DateTime object is being passed to the query and somehow being converted to a SQL datetime field in an improper manner.

In the query below SessionIdTime is a datetime field in SQL and I'm passing last_record[0] which is a mx.DateTime object. Not sure how to workaround this issue.

Any ideas?

sql = """
SELECT
    sd.SessionIdTime, sd.SessionIdSeq
FROM SessionDetails sd
WHERE sd.SessionIdTime > ?
    OR (sd.SessionIdTime = ? AND sd.SessionIdSeq > ?)
"""
 db = mx.ODBC.Windows.DriverConnect('DSN=OCS')
 conn = db.cursor()
 conn.execute(sql, (last_record[0], last_record[0], last_record[1]))


_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users