Skip to Content.
Sympa Menu

freetds - RE: [freetds] ODBC: SQLPrepare + repeated SQLExecute working?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] ODBC: SQLPrepare + repeated SQLExecute working?
  • Date: Mon, 17 Feb 2003 11:29:04 +0100

>
> Hi,
>
> Should prepared statements be working in the ODBC driver? I'm
> asking because I think I may
> have found another bug in the driver, but I'll spare you all
> yet another test program until
> I can determine that it's not working as advertised.
>
> Basically, this is what I'm doing in pseudocode:
>
> SQLBindParameter gid
> SQLBindCol uid
> SQLPrepare "SELECT gid FROM master..sysusers WHERE uid=?"
> for uid=0 to 100
> {
> SQLExecute
> if SQLFetch != SQL_NO_DATA
> print "gid is %d for uid %d", gid, uid
> }
>
> But it fails at the second iteration of the loop:
> SELECT gid FROM master..sysusers WHERE uid=0
> gid is 0 for uid 0
> SELECT gid FROM master..sysusers WHERE uid=1
> Error query -1
> [unixODBC][Driver Manager]Invalid cursor state (0)
>
> Am I trying something that isn't implemented yet? Does anyone
> know what 'Invalid cursor state'
> means in a case like this?
>
> Thanks again.
> My server is MS SQLserver 2k; my client is FreeTDS 0.61rc1
> CVS from Friday on RedHat 8 x86.
> I'm using unixODBC 2.2.2.
>

Hi Craig!
You should read all possible data before reissuing a SQLExecute, or call a
SQLCloseCursor after the fetch.

In code language

SQLBindParameter gid
SQLBindCol uid
SQLPrepare "SELECT gid FROM master..sysusers WHERE uid=?"
for uid=0 to 100
{
SQLExecute
if SQLFetch != SQL_NO_DATA
{
print "gid is %d for uid %d", gid, uid
SQLFetch // should return SQL_NO_DATA
}
SQLMoreResults // should return SQL_NO_DATA
}

Or

SQLBindParameter gid
SQLBindCol uid
SQLPrepare "SELECT gid FROM master..sysusers WHERE uid=?"
for uid=0 to 100
{
SQLExecute
if SQLFetch != SQL_NO_DATA
print "gid is %d for uid %d", gid, uid
SQLCloseCursor
}

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================




Archive powered by MHonArc 2.6.24.

Top of Page