Re: Loosing Control With Bad SQL

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.