freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
RE: [freetds] Reusing STMT handle for use with placeholders and data atexecution
- From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] Reusing STMT handle for use with placeholders and data atexecution
- Date: Fri, 4 Feb 2005 14:04:57 +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.
>
This is bad, it should at least give you an error...
> 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 '?'.
>
This seems a bug...
> Should I allways call FreeStmt with SQL_RESET_PARAMS before
> attempting
> to run a query using placeholders, or is this a bug somewhere?
>
I don't know....
>
> Call sequence:
> SQLPrepare(hstmt, "SELECT COUNT(x) ...", SQL_NTS);
> SQLExecute();
> SQLFetch();
> SQLGetData();
> SQLFreeStmt(hstmt, SQL_CLOSE);
>
Well.. here you should call more SQLFetch/SQLMoreResults to clear state
or use SQLCloseCursor, SQL_CLOSE it's normal.
> SQLBindParameter
> ...
> SQLPrepare(hstmt, "INSERT INTO x (a, b, c) VALUES (?, ?, ?)",
> SQL_NTS);
> SQLExecute
> SQLFreeStmt(hstmt, SQL_RESET_PARAMS);
>
here SQL_RESET_PARAMS should not be required. However remember that
binds from SQLBindParameter remains if you don't rebind params or not
reset params.
Can you post a ODBC dump and/or a FreeTDS dump?
freddy77
- RE: [freetds] Reusing STMT handle for use with placeholders and data atexecution, ZIGLIO, Frediano, VF-IT, 02/04/2005
Archive powered by MHonArc 2.6.24.