Saina Mohamadyari
Saina Mohamadyari

Reputation: 23

Automated rollback in Informix 14 database?

I have some scripts including DDL and DML transactions that use an Informix 14 database that I want to run some tests against.

If the tests fail they will often leave the database in an inconsistent state that needs to be manually resolved before the tests can be run again.

I would like to automate this so that the tests do not require manual intervention before running the tests again. So, is it possible to use rollback and savepoint without locking the database and run some tests on the database?

Upvotes: 2

Views: 216

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 754500

If you execute BEGIN WORK (or just BEGIN), then everything you do afterwards will be part of the same transaction until you explicitly execute COMMIT WORK (or just COMMIT) or ROLLBACK WORK (or just ROLLBACK) — or until your program exits without explicitly ending the transaction. If your program terminates unexpectedly or carelessly (without explicitly completing the transaction), the transaction will be rolled back.

The transaction will manage all the DDL and DML operations — with the sole exception of some caveats with the TRUNCATE TABLE statement. There are some restrictions on what you can do with the truncated table — basically, it cannot be modified again until the transaction completes.

Of course, this assumes your database is logged. You can't have transactional control in an unlogged database.

Upvotes: 1

Related Questions