Skip to Content.
Sympa Menu

freetds - Re: [freetds] Row-wise parameter array binding bug in 0.64

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Levente Tamási (IJ/ETH) <Levente.Tamasi AT ericsson.com>
  • To: "Ian Ashley" <iashley AT picdar.com>, "FreeTDS Mailing List" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Row-wise parameter array binding bug in 0.64
  • Date: Mon, 18 Sep 2006 11:40:54 +0200

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




Archive powered by MHonArc 2.6.24.

Top of Page