Salesforce

Are database sequences part of database transactions?

« Go Back

Information

 
TitleAre database sequences part of database transactions?
URL Name000027653
Article Number000145343
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: All supported versions
OS: All supported platforms
Question/Problem Description
Are database sequences part of database transactions?

Is the sequence value rolled back if a transaction is undone?

When using NEXT-VALUE against a database sequence inside of a transaction, is the sequence value rolled back if the transaction is undone?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Database sequences operate outside of the transaction mechanism (i.e. sequences do not get locked like records do). 

Once a NEXT-VALUE has been executed against a database sequence the sequence has been updated and will not be rolled back to its previous value.

The following example code shows how sequences are not rolled back.

Assuming a sequence named Fred with a current value of 5...
 
do transaction:
    create customer.

 /* increment the value of the sequence from 5 to 6 and returns 6 */
    assign customer.custnum = next-value(Fred). 

 /* force undo of transaction and rollback */
    undo, leave.                                
end.

/* this will display 6 because the sequence was incremented using next-value */
display current-value(Fred).                     
/* and sequences do not get rolled back   */

The following Articles outline the consequences of Sequences outside of the transaction mechanism
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 6:55 AM

Powered by