Difference between revisions of "Rollback"
From AgileApps Support Wiki
imported>Aeric m (Text replace - 'rollbackToSavePoint(' to 'Functions.rollbackToSavePoint(') |
imported>Aeric |
||
Line 48: | Line 48: | ||
Functions.addSavePoint("second_save_point"); | Functions.addSavePoint("second_save_point"); | ||
Logger.info("Second Save Point :" | |||
+ Functions.doesSavePointExist("second_save_point"), "Rollback"); | |||
Parameters secondParams = Functions.getParametersInstance(); | Parameters secondParams = Functions.getParametersInstance(); | ||
Line 89: | Line 90: | ||
Functions.addSavePoint("second_save_point"); | Functions.addSavePoint("second_save_point"); | ||
Logger.info("Second Save Point: " | |||
+ doesSavePointExists("second_save_point"), "Rollback"); | |||
Parameters secondParams = Functions.getParametersInstance(); | Parameters secondParams = Functions.getParametersInstance(); |
Latest revision as of 22:30, 10 September 2013
- Functions.rollback(String name)
- Performs a rollback of the entire transaction
- Syntax
void Functions.rollback()
- Return
- None
Examples
Single SavePoint Rollback
Rollback a record to the values contained in the last SavePoint
Functions.addSavePoint("save_point"); Parameters params = Functions.getParametersInstance(); params.add("first_name","Jack"); params.add("last_name","Nicholson"); Result result = Functions.addRecord("CONTACT",params); Functions.rollbackToSavePoint("save_point");
Multiple SavePoints Rollback
Restores multiple SavePoints to the initial state, and rolls back all of the addRecord actions.
Functions.addSavePoint("save_point"); Parameters params = Functions.getParametersInstance(); params.add("first_name","Jack"); params.add("last_name","Nicholson"); Result result = Functions.addRecord("CONTACT",params); Functions.addSavePoint("second_save_point"); Logger.info("Second Save Point :" + Functions.doesSavePointExist("second_save_point"), "Rollback"); Parameters secondParams = Functions.getParametersInstance(); secondParams.add("first_name","Anthony"); secondParams.add("last_name","Hopkins"); Result secondResult = Functions.addRecord("CONTACT",secondParams); Functions.addSavePoint("third_save_point"); Parameters thirdParams = Functions.getParametersInstance(); thirdParams.add("first_name","Clint"); thirdParams.add("last_name","Eastwood"); Result thirdResult = Functions.addRecord("CONTACT",thirdParams); Functions.rollbackToSavePoint("save_point");
Rollback Entire Transaction
Roll back a series of transactions, to the original SavePoint.
- From the web browser these results are seen:
- If a record was added before this transaction, then the record will not exist
- If a record was edited before this transaction, then no updates will be recorded for the record
Functions.addSavePoint("save_point"); Parameters params = Functions.getParametersInstance(); params.add("first_name","Jack"); params.add("last_name","Nicholson"); Result result = Functions.addRecord("CONTACT",params); Functions.addSavePoint("second_save_point"); Logger.info("Second Save Point: " + doesSavePointExists("second_save_point"), "Rollback"); Parameters secondParams = Functions.getParametersInstance(); secondParams.add("first_name","Anthony"); secondParams.add("last_name","Hopkins"); Result secondResult = Functions.addRecord("CONTACT",secondParams); Functions.rollback(); // rollbacks all batabase operations like insert, update and delete before this. Functions.addSavePoint("third_save_point"); Parameters thirdParams = Functions.getParametersInstance(); thirdParams.add("first_name","Client"); thirdParams.add("last_name","Eastwood"); Result thirdResult = Functions.addRecord("CONTACT",thirdParams);