Skip to main content

exec sql begin tran and autocommit

  • May 30, 2017
  • 2 replies
  • 0 views

Dominique Sacre
Forum|alt.badge.img+2

Hi,

I'm running some programs in exec sql autocommit mode which I have as a compiler option (Windows VC 2.3.2 on VS 15) with MySQl.

For a short section I want to run in a transaction and commit at the end.

What is the right combination of exec sql statements to achieve this i.e.

(1) running in autocommit, quite a few updates done, interacting with users via dialog system etc.

(2) now want to run a few updates as a transaction and only commit at the end

(3) then return to autocommit

In my testing, it seems to work if I exec sql begin tran immediately after the connect but if quite a lot has happened in the interim it just seems to commit and ignore my begin tran.

Any thoughts?

Thanks a lot,

Linden

 

 

 

2 replies

Dominique Sacre
Forum|alt.badge.img+2

Hi,

I'm running some programs in exec sql autocommit mode which I have as a compiler option (Windows VC 2.3.2 on VS 15) with MySQl.

For a short section I want to run in a transaction and commit at the end.

What is the right combination of exec sql statements to achieve this i.e.

(1) running in autocommit, quite a few updates done, interacting with users via dialog system etc.

(2) now want to run a few updates as a transaction and only commit at the end

(3) then return to autocommit

In my testing, it seems to work if I exec sql begin tran immediately after the connect but if quite a lot has happened in the interim it just seems to commit and ignore my begin tran.

Any thoughts?

Thanks a lot,

Linden

 

 

 

Answered my own question... Realised I'm using the MySQL 'MyISAM' engine on some tables and that doesn't support transactions; it just ignores and auto commits. I've switched key tables to MySQL's default, 'InnoDB' engine and the transactions are working fine.


Dominique Sacre
Forum|alt.badge.img+2

Hi,

I'm running some programs in exec sql autocommit mode which I have as a compiler option (Windows VC 2.3.2 on VS 15) with MySQl.

For a short section I want to run in a transaction and commit at the end.

What is the right combination of exec sql statements to achieve this i.e.

(1) running in autocommit, quite a few updates done, interacting with users via dialog system etc.

(2) now want to run a few updates as a transaction and only commit at the end

(3) then return to autocommit

In my testing, it seems to work if I exec sql begin tran immediately after the connect but if quite a lot has happened in the interim it just seems to commit and ignore my begin tran.

Any thoughts?

Thanks a lot,

Linden

 

 

 

Answered my own question... Realised I'm using the MySQL 'MyISAM' engine on some tables and that doesn't support transactions; it just ignores and auto commits. I've switched key tables to MySQL's default, 'InnoDB' engine and the transactions are working fine.