Can multiple database operations be done in a single atomic transaction?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2015 06:22 AM
I am looking for a way to perform multiple database operations as a single atomic transactions, such that either all database operations succeed or none of them. In practice this typically involves marking the start of a transaction, perform all operations and then either end the transaction if all successful or, on failure, rollback all database operations since the marked transaction start. An example in pseudo could could be:
TRANSACTION_START( );
while( record.next( ) ) {
record.someField += 1;
record.update( );
}
TRANSACTION_END( );
In this example we update all records we've found and set someField to its value +1. Now if any of these updates fails, e.g. due to a business rule or ACL, all of the updates should be reverted (for whatever reason). Is there any such a construction present in the GlideAPI? The features documented in the wiki do not describe such a thing, while (I think) all DB engines implement this (see e.g. Introduction to Transactions - SQLTeam.com)
Thanks in advance,
Joris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2015 06:56 AM
Hi Joris,
We do not have this functionality on GlideAPI. We rely on the database side for all ACID operations as we are using transactional engines on the database side (as example, we use InnoDB engine on MySQL).
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2015 07:21 AM
You could probably accomplish this with gs.sql(), but:
Why using gs.sql is a BAD IDEA!
You have to very careful and know exactly what you are doing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 03:33 PM
5 years from starting this topic. is smth changed since then?
lack of database transactions support is really annoying and lead to overcomplexity of development.