[egenix-users] Empty strings and executedirect

M.-A. Lemburg mal at egenix.com
Tue May 15 00:40:15 CEST 2007


On 2007-05-14 16:01, Tommi Auvinen wrote:
> Environment: Windows client and SQLServer. Python 2.43 and mxODBC 2.0.7.
> 
>  
> 
> When I do the following insert using execute direct (C = char,
> VC=varchar etc.)
> 
> "INSERT INTO Testi (C, VC, NC, NVC) VALUES (?,?,?,?)"
> 
>  
> 
> using parameters ("", "",""; "")
> 
>  
> 
> the resulting insert is as follows
> 
> exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES
> (@P1, at P2, at P3, at P4)',N'@P1 char(8000), at P2 char(8000), at P3 char(8000), at P4
> char(8000) ...
> 
> ...and the data for each fields really is 8000 spaces.
> 
>  
> 
> The same using strings with one space (" ", " "," "; " ") works as
> expected: 
> 
> exec sp_executesql N'INSERT INTO Testi (C, VC, NC, NVC) VALUES
> (@P1, at P2, at P3, at P4)',N'@P1 char(1), at P2 char(1), at P3 char(1), at P4 char(1)','
> ',' ',' ',' '
> 
>  
> 
> So, am I missing something and or is this a bug? 

This looks a lot like a bug in the ODBC driver.

It seem to convert the empty data to a char(8000) column (which
is padded with spaces in SQL Server and many other database backends).

OTOH, you could also view it as bug in the way the one character
data is handled. Depends on the table schema. If this is indeed
a char(8000) column, then the one character data should also be
padded to 8000 characters.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 14 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the egenix-users mailing list