Re: Transactions errors with DBD-Sybase-1.05

Michael Peppler <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase
Message-ID <[email protected]>
On Wed, 2005-03-23 at 14:45, David Barnwell wrote:
> Hi Michael,
> 
> Thanks for your mail.
> 
> > Why do you call finish() here?
> 
> I tried it without the $sth->finish. I now get a similar error with
> DBD-Sybase-1.04, but this time the commit fails rather than the execute, and
> the rollback is successful. To summarise:
> 
> with the $sth->finish statement:
>   DBD-Sybase-1.04 OK
>   DBD-Sybase-1.05 execute fails, rollback fails silently.
> 
> without the $sth->finish statement:
>   DBD-Sybase-1.04 commit fails, rollback succeeds

If you check the trace you'll see that the commit fails because of an
"attempt to initiate command with results pending" error.

The $sth->finish call shouldn't be called to flush all results as it may
call ct_cancel() (which wouldn't do what you want). Instead you should
use a loop - something like

REDO: {
   while(my $r = $sth->fetch) {
	;
   }
   redo REDO if($sth->{syb_more_results});
}



>   DBD-Sybase-1.05 execute fails, rollback fails silently

You've found a bug when using AutoCommit when CHAINED transactions
aren't supported/available.

I'll have to look at the code to see what has changed (I suspect that I
moved the execute() call to a different place, so that the BEGIN TRAN
now gets called too late).

Michael
-- 
Michael Peppler  -  [email protected]  -  http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html
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.