Transaction in transaction

Questions and answers regarding general SQL and backend databases

Transaction in transaction

Postby udrescu_bogdan » Wed Oct 05, 2011 12:16 am

Hi guys,

Can I use 2 transaction, one started after the first one and closed before it? Will the changes made after the second one starts be commit or rollback when it closes? And the changes made between the first start and the second start and between the second commit/rollback and the first commit/rollback will be saved/or canceled when the first transaction ends.

I hope you can understand what I just said, otherwise I'll draw it. :wink:

I want to open a form with save/cancel buttons but from that form others dialogs can be opened, each of them with their save/cancel buttons. Any recommendation?

Thanks,
Bogdan.
udrescu_bogdan
 
Posts: 336
Joined: Fri Jun 18, 2010 3:27 pm
Location: Craiova, Romania

Re: Transaction in transaction

Postby rgansevles » Fri Oct 07, 2011 8:58 am

Bogdan,

Servoy does not support nested transactions.
The second startTransaction does nothing and the first commit/rollback already works with all changed records.

Also note that database transactions should be used only in very short actions.
When user interaction is involved after the transaction is started this may block other people accessing the db.
Suppose a user opens your dialog just before his holiday and forgets to close it.

Instead better to use auto-save off and databaseManager.saveData()/rollbackeditedrecords.
Unfortunately, this does not support deletes, these are done in the db, regardless of the autosave state.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Transaction in transaction

Postby ROCLASI » Fri Oct 07, 2011 9:23 am

Hi Bogdan,

As Rob explained you can't use nested transactions.The only thing that comes close is to use savepoints. A quick search around showed me that pretty much all the SQL vendors support this one way or another.
So with some plain SQL (and the rawSQL plugin) you could set and rollback to a specific savepoint inside the transaction (and keep the transaction active) when needed.
Just google for it.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 38 guests