[freetds] DBD::ODBC (perl) and SQLDescribeParam

James K. Lowden jklowden at freetds.org
Mon Jul 27 23:06:23 EDT 2009

Michael Higgins wrote:
> Without SQLDescribeParam, DBD::ODBC, doesn't know how to cast so to bind
> place holders (?) and SQL Server 2000 (for example) throws an error on
> some columns when preparing a statement. Like the 'money' data_type.
> Default data_type is wrong (s/b like, decimal anyway), I hear, because
> there's nothing from the driver to tell us what it is. No
> SQLDescribeParam, so the prepare call always fails. (I'd like to think
> there was something else returned that would provide the column data
> type when preparing a statement, but I can't make sense of any of this
> code -- and this is just what I've been told.)


At the ODBC level, SQLBindParameter takes two datatype descriptors: 

ValueType	[Input] The C data type of the parameter. 
ParameterType	[Input] The SQL data type of the parameter. 


You can call DBI->bind_param with a third argument to indicate the SQL

> So is there any current development to get this API hook, or whatever it
> is called, implemented in FreeTDS? I did see it marked TODO...
> "SQLDescribeParam (Sybase seems to require it)". 

There are no plans other than waiting for Batman to show up with an SQL
parser, no.  The ct-lib API does not require (or permit) the application
to provide the SQL datatype; instead it interrogates the server.  Because
only Sybase servers provide that support, FreeTDS's ct-lib parameter
binding doesn't work with Microsoft servers.  



More information about the FreeTDS mailing list