Skip to Content.
Sympa Menu

freetds - [freetds] Question about FreeTDS, DBD::ODBC and bind parameters with prepar ed statements

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Will.Saxon AT sage.com
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Question about FreeTDS, DBD::ODBC and bind parameters with prepar ed statements
  • Date: Thu, 30 Apr 2009 09:44:47 -0400

Hello,

I emailed dbi-users with this question and the author of DBD::ODBC suggested
this may be a FreeTDS issue.

I am using Perl 5.10, FreeTDS 0.82, DBI 1.605 and DBD::ODBC 1.13 against an
MS SQL Server 2008 machine.

If I try to prepare a statement containing placeholders for fields with a
binary datatype, I get the following error:

DBD::ODBC::db prepare failed: [unixODBC][FreeTDS][SQL Server]Statement(s)
could not be prepared. (SQL-42000)
[unixODBC][FreeTDS][SQL Server]Implicit conversion from data type varchar to
binary is not allowed. Use the CONVERT function to run this query.
(SQL-22018)(DBD: st_prepare/SQLPrepare err=-1)

The documentation for DBD::ODBC suggests that this can happen if the driver
does not support SQLDescribeParam. In these cases a default parameter type
of SQL_VARCHAR is used.

I've tried changing the default parameter type to SQL_BINARY, but I still
receive the above error when trying to prepare a statement. I've also looked
for a way to specify the parameter type at the time I prepare the statement,
but there doesn't appear to be a way to do this (specifying the TYPE
attribute in the prepare statement has no effect).

Is this supposed to work, i.e. am I just 'doing it wrong'? As far as I know
the only way to get placeholder support in prepared statements with FreeTDS
and DBI is DBD::ODBC, is that correct?

Thanks for any assistance.

-Will

--
Will Saxon
Systems Administrator III
Sage
Healthcare Division
13545 Progress BLVD
Alachua, FL 32615
Tel: 386.418.7341
Fax: 813.207.9753
William.Saxon AT sage.com
www.sagehealth.com



  • [freetds] Question about FreeTDS, DBD::ODBC and bind parameters with prepar ed statements, Will . Saxon, 04/30/2009

Archive powered by MHonArc 2.6.24.

Top of Page