Skip to Content.
Sympa Menu

freetds - [freetds] Reusing STMT handle for use with placeholders and data at execution

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frode Nordahl <frode AT nordahl.net>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Reusing STMT handle for use with placeholders and data at execution
  • Date: Thu, 3 Feb 2005 09:32:37 +0100

Hello,

I have a small application that first does a quick query to check something, then goes on to insert or update something based on the results of the first query.

However, the second query fails, without any errors from GetDiagRec, unless I call SQLFreeStmt with both SQL_CLOSE and SQL_RESET_PARAMS.

I ran SQL Profiler on the server, and saw that the actual query also changed. Normally the placeholders are replaced with variable names, but when not calling FreeStmt with SQL_RESET_PARAMS first, they show up as '?'.

Should I allways call FreeStmt with SQL_RESET_PARAMS before attempting to run a query using placeholders, or is this a bug somewhere?


Call sequence:
SQLPrepare(hstmt, "SELECT COUNT(x) ...", SQL_NTS);
SQLExecute();
SQLFetch();
SQLGetData();
SQLFreeStmt(hstmt, SQL_CLOSE);

SQLBindParameter
...
SQLPrepare(hstmt, "INSERT INTO x (a, b, c) VALUES (?, ?, ?)", SQL_NTS);
SQLExecute
SQLFreeStmt(hstmt, SQL_RESET_PARAMS);


Regards,
Frode




  • [freetds] Reusing STMT handle for use with placeholders and data at execution, Frode Nordahl, 02/03/2005

Archive powered by MHonArc 2.6.24.

Top of Page