Re: DBD::ODBC (perl) and SQLDescribeParam

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
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.)

http://msdn.microsoft.com/en-us/library/ms710963(VS.85).aspx

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. 

http://search.cpan.org/~mjevans/DBD-ODBC-1.22/ODBC.pm#odbc_default_bind_type
http://search.cpan.org/~timb/DBI-1.609/DBI.pm#bind_param

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

> 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.  

HTH.  

--jkl
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.