[freetds] Question about FreeTDS odbc.c and SQL_ATTR_ROW_BIND_TYPE
smurph at smcomp.com
Fri Jun 27 18:28:18 EDT 2003
There is a patch at the FreeTDS sourceforge site that introduces a whole new
odbc driver called libmsodbc. It might still apply against -current. This
will eliminate your application from bombing because the
SQL_ATTR_ROW_BIND_TYPE attribute is supported for SQL_BIND_BY_COLUMN, but
only SQL_BIND_BY_COLUMN. Binding a row into a buffer or structure is not
yet supported. If you are handy at applying patches then this might be a
alternative. freetds.conf is not used with libmsodbc and it also contains a
unixODBC setup function. libmsodbc.so should be both your driver lib and
your setup lib. Use ODBCConfig to set up your DSN after libmsodbc is
installed to see all of the driver settings. Most duplicate the settings
that are in freetds.conf so you can use it's values for the new drivers
To modify your existing FreeTDS code, simply add the SQL_ATTR_ROW_BIND_TYPE
attribute in the case statement and just do nothing if the value of the
attribute is SQL_BIND_BY_COLUMN. Again, only SQL_BIND_BY_COLUMN is
implemented in the current driver, so a value other than SQL_BIND_BY_COLUMN
should return the HYC00 "Driver Not Capable" error. Heh, because it isn't.
Also, according to the ODBC API, SQL_BIND_BY_COLUMN is the default row bind
type. If the a driver conforms to the ODBC API, setting this attribute to
SQL_BIND_BY_COLUMN is not needed. You might take out your call to
SQLSetStmtAttr() and the application will most likely survive with other
ODBC API compliant drivers also.
The ODBC APT can be found at:
>From the ODBC API:
"An SQLUINTEGER value that sets the binding orientation to be used when
SQLFetch or SQLFetchScroll is called on the associated statement.
Column-wise binding is selected by setting the value to SQL_BIND_BY_COLUMN.
Row-wise binding is selected by setting the value to the length of a
structure or an instance of a buffer into which result columns will be
"If a length is specified, it must include space for all of the bound
columns and any padding of the structure or buffer to ensure that when the
address of a bound column is incremented with the specified length, the
result will point to the beginning of the same column in the next row. When
using the sizeof operator with structures or unions in ANSI C, this behavior
"Column-wise binding is the default binding orientation for SQLFetch and
----- Original Message -----
From: "Arjona, Ramon" <Ramon.Arjona at wizards.com>
To: <freetds at lists.ibiblio.org>
Sent: Friday, June 27, 2003 11:10 AM
Subject: [freetds] Question about FreeTDS odbc.c and SQL_ATTR_ROW_BIND_TYPE
> I'm using FreeTDS version 0.61 on Red Hat Linux with version 2.2.2 of
> unixODBC. I'm connecting to an MS SQL 2000 box using TDSVER=8.0.
> The application we're running is written in C/C++.
> The problem that I am having is this: I am attempting to call
> SQLSetStmtAttr as follows:
> stat = SQLSetStmtAttr(mycmd, SQL_ATTR_ROW_BIND_TYPE, SQL_BIND_BY_COLUMN,
> This falls through into SQLSetStmtOption in odbc.c. This function then
> falls through to the error handler, logging the message that
> "odbc:SQLSetStmtOption: Statment option 5 not implemented" which in turn
> causes the application to dump core.
> My questions are as follows:
> 1) What should be the appropriate idiom to work around this problem in
> FreeTDS? Should I just comment out the set attribute statement or is
> there some other approach I ought to take.
> 2) If I were to attack the problem at odbc.c itself and attempt to
> implement this function & option, can anyone reccomend a set of useful
> reference documentation?
> Any input is appreciated.
> Thank you,
> The Master says, 'Man who falls in vat of molten glass makes spectacle
> of himself.'
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
More information about the FreeTDS