Skip to Content.
Sympa Menu

freetds - Re: [freetds] Loosing Control With Bad SQL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Loosing Control With Bad SQL
  • Date: Thu, 30 Sep 2010 23:39:51 -0400

Ken Collins wrote:
>
> dbcmd(dbproc,sql); // sql = "SELECT * FROM [foobar]"
> dbsqlsend(dbproc);
> dbsqlok(dbproc);
>
> I can never get dbsqlexec or dbsqlok to return a status, just seems my
> program stops at that point. So the next time I come back around to
> putting something in the command buffer and executing it, I get a
> "Attempt to initiate a new Adaptive Server operation with results
> pending" error.

http://manuals.sybase.com/onlinebooks/group-cnarc/cng1110e/dblib/@Generic__BookTextView/40525;pt=39614

"Once dbsqlexec returns SUCCEED, the application must call dbresults
to
process the results."

The library does not know that the server returned no results; it stopped
listening when the SQL was acknowledged. Call dbresults() to confirm
there's nothing pending before issuing your next query.

N.B. The library can know, because the TDS_DONE packet indicates whether
or not more results follow. That's how it knows whether to attempt to
read more data from the stream. The state management might be a little
too conservative in this case, even if it's within spec.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page