[egenix-users] "right truncation" warning in mx.ODBC.Windows

Charles Bearden Charles.F.Bearden at uth.tmc.edu
Fri Mar 5 12:29:07 CET 2004


I'm using mx.ODBC version 2.0.1 (that's the version in
site-packages\mx\ODBC\ODBC.py; the "commercial" download file is version
2.0.6) with ActivePython 2.3.2 Build 230 to talk to a MS SQL Server.  I
am having a puzzling right truncation problem when trying to insert even
small values into a table.  In order to isolate variables, I am
inserting values into only required (non-NULL) fields.  INSERTing the
same values into the table works via Query Analyzer.  Here is sample
code, traceback, & the table definition.  Any ideas on how to make this
work would be greatly appreciated--thanks in advance!

--------------------------begin snippet-----------------------------
import time
from mx.ODBC.Windows import DriverConnect
import mx.DateTime

con = DriverConnect("DSN=theDb;UID=theUser;PWD=thePwd")
cur = con.cursor()

datestmp = mx.DateTime.localtime(time.time())

val_t = (10073787, 0, datestmp, 1)

ins_stmnt = '''
  INSERT INTO pmLinkHistory
  ('PMID', 'Ord', 'LastActionDate', 'LastAction')
  VALUES
  (?, ?, ?, ?)
'''
cur.execute(ins_stmnt, val_t)
con.close()

-------------------------begin traceback----------------------------

Traceback (most recent call last):
  File "./simpletest.py", line 18, in ?
    cur.execute(ins_stmnt, val_t)
mxODBC.Warning: ('22001', 0, '[Microsoft][ODBC SQL Server Driver]String
data, right truncation', 4579)

-------------------------begin table def----------------------------

CREATE TABLE [dbo].[pmLinkHistory] (
        [ID] [int] IDENTITY (1, 1) NOT NULL ,
        [PMID] [int] NOT NULL ,
        [Ord] [smallint] NOT NULL ,
        [LastActionDate] [datetime] NOT NULL ,
        [LastAction] [smallint] NOT NULL ,
        [Info] [nvarchar] (24) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
,
        [Url] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CS_AS
NULL ,
        [LinkName] [nvarchar] (256) COLLATE SQL_Latin1_General_CP1_CS_AS
NULL ,
        [Provider] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CS_AS
NULL ,
        [Notes] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CS_AS
NULL
) ON [PRIMARY]

--------------------------end table def-----------------------------
(The table also has a normal primary key comprising PMID and Ord.  No
other indices, triggers, or stored procedures.)


Chuck Bearden
Systems Analyst III
School of Health Information Sciences
University of Texas at Houston
713.500.3954 (voice)
713.500.3907 (fax)
Charles.F.Bearden at uth.tmc.edu
 



More information about the egenix-users mailing list