Re: Question about FreeTDS, DBD::ODBC and bind paramete rs with prepar ed statements

[email protected]
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] 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 <[email protected]>
> >
> > [email protected] 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
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.