Skip to Content.
Sympa Menu

freetds - RE: [freetds] Inserting empty strings into MS SQL Server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Joseph Geiser" <joe AT mail.paravisions.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Inserting empty strings into MS SQL Server
  • Date: Mon, 9 Aug 2004 14:06:17 -0400

Charles Bearden writes,

> I am trying to avoid NULLs in my columns and am finding that the empty
> string works as a substitute for almost all cases where I would have
> used a NULL in the past. However, when I pass empty strings as values
> in the tuple second argument to the execute method (e.g.
> 'cu.execute(stmnt, tpl)'), the following exception is raised:

Not knowing the data types you are passing, here is something to keep in
mind.

Numeric data can be NULL in SQL Server, and passing a NULLable value to a
numeric column is permitted. What is NOT permitted however, is passing an
empty string to a numeric column, and this looks like what might be
occurring here.

Check data types - and if you must use something other than NULL in
numerics, and we do not permit it here, we use Defaults - default all
numerics to zero or other value that would make sense. For Dates, we do not
use null dates - we either default to getdate() (current date/time) or for
an undefined date, we use '2100-12-31 00:00:00' - well enough into the
future that this system will very well be replaced by then.

HTH,

Regards,
Joe Geiser

<<attachment: winmail.dat>>




Archive powered by MHonArc 2.6.24.

Top of Page