Rolling back all transactions when writing to multiple tables using 4GL

SOLVED

So I know how I can write a transaction for a table and if there's an error, rollback the changes.

How would I go about doing this if I wanted to rollback multiple changes to multiple tables?

e.g. I'm trying to write to four tables [BPR], [BPS], [BPA], [BID]

Doing each one individually, if the first three were successful but the fourth wasn't, the data would be written to the first three and not the fourth?

Trbegin [BPR]

If !fstat
    Write [F:BPR]
    Commit
Else
    Rollback
Endif

Top Replies

  • Hello .

    You can use a control variable, say YCOMMIT.
    After writing each table, check if the record exists and keep that variable with a positive value, say 2.

    Before your commit, check if the…