Skip to Content.
Sympa Menu

freetds - Re: [freetds] Question about FreeTDS, DBD::ODBC and bind paramete rs 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: Re: [freetds] Question about FreeTDS, DBD::ODBC and bind paramete rs with prepar ed statements
  • Date: Thu, 7 May 2009 12:52:23 -0400



> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of
> Frediano Ziglio
> Sent: Tuesday, May 05, 2009 10:33 AM
> To: FreeTDS Development Group
> Subject: Re: [freetds] Question about FreeTDS, DBD::ODBC and
> bind parameters with prepar ed statements
>
> 2009/5/5 James K. Lowden <jklowden AT freetds.org>
> >
> > Will.Saxon AT sage.com wrote:
> > > 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.
> >
> > $ grep SQLDescribeParam doc/api_status.txt
> > odbc    (all)   SQLDescribeParam        unimplemented
>
> Yes, currently not implemented... it require sql parsing. Note however
> that I used many time DBD::ODBC specifying parameters type before to
> override default. Just use third bind_param argument

Unfortunately, this is not helpful if you want to prepare a statement with a
parameter of a data type that is not able to be implicitly converted to
SQL_VARCHAR. If all of your parameters can be converted the statement
preparation succeeds. If you have any parameters of data types which are not
convertible (e.g. SQL_BINARY), the statement preparation fails.

It doesn't appear to be possible to specify parameter datatypes while
preparing a statement, so unless that is changed or until FreeTDS implements
SQLDescribeParam, I don't think it will be possible to use prepared
statements with data types that are not convertible to SQL_VARCHAR.

-Will

>
> freddy77
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>



  • Re: [freetds] Question about FreeTDS, DBD::ODBC and bind paramete rs with prepar ed statements, Will . Saxon, 05/07/2009

Archive powered by MHonArc 2.6.24.

Top of Page