exec sql begin tran and autocommit


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,