DBI begin_work doesn't work with stored procedure calls

后端 未结 2 1938
别那么骄傲
别那么骄傲 2021-01-22 12:24

I am trying to make a call to a stored procedure from with in a transaction in its simplified form:

my $dbh= DBI->connect(............  );  

my $sth = $dbh-&         


        
2条回答
  •  粉色の甜心
    2021-01-22 12:55

    If you are using AutoCommit => 0, then you don't need begin_work(). Everything is in a transaction until you commit() or rollback(). Then a new transaction begins.

    Actually, you should connect with RaiseError => 1, because you should get an error on begin_work() when AutoCommit is 0. From the fine docs:

    If AutoCommit is already off when begin_work is called then it does nothing except return an error. If the driver does not support transactions then when begin_work attempts to set AutoCommit off the driver will trigger a fatal error.

    Also, what version of DBD::mysql are you using? I think the latest version does implement AutoCommit.

提交回复
热议问题