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: Ken Collins <ken AT metaskills.net>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Loosing Control With Bad SQL
  • Date: Mon, 4 Oct 2010 11:37:54 -0400


Dan, I did know about dbcanquery and it was not a fit for my use at this
specific point in the code and I do use it elsewhere.

James, I read that about dbresults in the docs too, my problem was that it
appears after that after calling dbsqlexec, it does not return and stops
execution of my code once my message handler get's the message. I'll let you
know when I round back to that area. Right now I have a few hacks in my
message handler that cleans up when this occurs by calling dbsqlok and
dbcancel.


- Ken


On Sep 30, 2010, at 11:39 PM, James K. Lowden wrote:

> 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
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds




  • Re: [freetds] Loosing Control With Bad SQL, Ken Collins, 10/04/2010

Archive powered by MHonArc 2.6.24.

Top of Page