[freetds] Loosing Control With Bad SQL

Ken Collins ken at metaskills.net
Mon Oct 4 11:37:54 EDT 2010


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




More information about the FreeTDS mailing list