[freetds] Row-wise parameter array binding bug in 0.64
Levente Tamási (IJ/ETH)
Levente.Tamasi at ericsson.com
Mon Sep 18 05:40:54 EDT 2006
Hi Ian,
The following works against Microsoft SQL Server 2005 (error checking etc. omitted for clarity), using unixODBC 2.2.11 and freetds 0.64 with the post-0.64 patches applied:
<snip>
#define NUMBER_OF_ROWS 32
struct row
{
int c1;
SQLINTEGER c1Callback;
double c2;
SQLINTEGER c2Callback;
};
struct row rows[NUMBER_OF_ROWS];
std::string insertString = "INSERT INTO t1(c1, c2) VALUES (?, ?);";
// set attributes for row-wise binding
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, (SQLPOINTER) sizeof(struct row), 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) NUMBER_OF_ROWS, 0);
// prepare statement
SQLPrepare(hstmt, (SQLCHAR *) insertString.c_str(), SQL_NTS);
// bind parameters
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DEFAULT, SQL_INTEGER, 0, 0, &rows[0].c1, 0, &rows[0].c1Callback);
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_DEFAULT, SQL_DOUBLE, 0, 0, &rows[0].c2, 0, &rows[0].c2Callback);
</snip>
After that, you can fill in the value holder structure (rows[]), and a call to SQLExecute() should insert NUMBER_OF_ROWS records. At least it does on SQL Server. BTW, what are the symptoms on your system?
Cheers,
Levi
More information about the FreeTDS
mailing list