vcoderv has asked for the wisdom of the Perl Monks concerning the following question:

Hi there --- since i dint get a concise answer to my first posting, may be this would (hopefully) work:

1. I need to connect to a Sybase server
2. I need to start a new transaction
3. I need to execute a SP, lets say 5 times that does some inserts/updates
4. If no errors, after all 5 calls, commit, else rollback

Any help is appreciated !! THANK YOU!!
  • Comment on DBD Sybase Transaction begin_work fails , post #2

Replies are listed 'Best First'.
Re: DBD Sybase Transaction begin_work fails , post #2
by Sewi (Friar) on Sep 16, 2009 at 15:00 UTC
    You didn't write a question or problem at all.
    1. DBD::Sybase has pretty good examples for this.
    2. If you set AutoCommit off, there is no need to explicit do this.
    3. A simple ->do should do this when being used on your conn handle
    4. You said it. errstr, commit and rollback are your friends

      ....yes, thank you.. The problem is when I explicitly want to rollback the changes..
      here, assuming i have a dbh and sth:

      my $sth = $dbh->prepare("exec PerlTest2 \@RetVal = ? OUTPUT, \@SomePar +am = ? "); $sth->bind_param(1, undef, SQL_INTEGER); $sth->bind_param(2, "val1", SQL_VARCHAR); $sth->execute; # first batch exec $sth->bind_param(1, undef); $sth->bind_param(2, "val22"); $sth->execute; # exec some more $sth->finish; $dbh->rollback; # <---- still records get committed into the dB !!! print "finishing...\n"; $dbh->disconnect; close dbh;

        Shouldn't that be in this order:

        $dbh->rollback; # <---- still records get committed into the dB !!! $sth->finish;

        Also, DBD::Sybase says something about $h->{AutoCommit}... Did you set that to off somewhere?