> > > Hi all. > > I've just ( barely ) managed to get DBD::ODBC ==> UnixODBC > ==> FreeTDS > working on my system. > > I took a Perl-Gtk2 app which has been running fine, and > substituted the > old DBD::Sybase connection with the DBD::ODBC one, and then > discovered I > could only run one query on SQL Server, and then all > subsequent queries > gave: > > DBD::ODBC::st execute failed: [unixODBC][FreeTDS][SQL > Server]Attempt to > initiate a new SQL Server operation with results pending. > (SQL-07005)(DBD: st_execute/SQLExecute err=-1) > > Damn! > > So I started going through my code and adding $sth->finish after all > recordset operations, and that seems to be fixing things.
Please see if you can provide a small, self-contained example. (i.e. one that creates tables and inserts data, then reproduces the problem, such that it can be run simply (or, feel free to add it to some of the DBD::ODBC t/20sqlserver.t tests, if you feel slightly more inclined), then I can refine the implementation to ensure that you don't have to call finish each time. It's supposed to be that way, but if it's not working, I'd like to know. Also, I thought that DBD::Sybase had some work around/automatic fix for multiple concurrent statements -- so it may be that you haven't finished retrieving all results, but DBD::Sybase is smarter about it. One final thing, try looking at DBD::ODBC's attribute: odbc_curstortype. See the pod in DBD::ODBC and example in t/20SqlServer.t > > Why is this happening? Surely if I loop through a recordset until the > end, the drivers should figure out that there are no more results > pending? That's at least what happens with all the other drivers I've > used. Is there an alternative to adding $sth->finish at the > end of each > recordset operation? Yep, it should be, but if it isn't and you can provide a sample, I'll see if it can be fixed. > > What happens if I have a sub that creates a $sth and loops through it > and then exits. The $sth goes out of scope, right? Is this > sufficient, > or do I have to $sth->finish in these cases as well? The sth going out of scope should do it too... Jeff