Any DB transaction method supported?

youming2007
Kilo Contributor

Hi all,

I've looked into GlideRecord API but there isn't any method to handle DB transaction (rollback/commit). I have 2 questions as below:

Question 1:

In server script, I have a while loop to insert 3 records at the same time. The requirement is all 3 records are committed or nothing is committed. In case record 2 is inserted unsuccessfully, I want to rollback record 1. Is there any way to do that?

 

Question 2:

In case of using Embedded list, when submitting form, all embedded records are submitted along with the parent record. The parent record is inserted first, then each embedded record. If there is error with any embedded record, I want to rollback the entire transaction. Is it possible? How?

 

Thanks in advance.

2 REPLIES 2

Gaurav Bajaj
Kilo Sage

Hi,

GlideRecord doesn't provide you commit/rollback features but you can certainly deal with your scenario through basic javascript function and GlidRecord.

e.g. for the 1st scenario, you can insert a record and if you see 2nd one is not inserted, you can always delete the first one by keeping the first record number in an array.

 

Thanks

Gaurav

 

This is not the right solution. It does not provide a transaction-level integrity. It is cumbersome if the number of records increases from 3 to a very higher number say 1 million.