Give a warning when CURRENT-VALUE(SomeSequence) / DYNAMIC-CURRENT-VALUE is assigned to a table field.

Project:Prolint Issue Tracker
Component:Rules
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Description

The usual use of a sequence is to have a fast way get a guaranteed unique ID for a new record of a specified table.

Because multiple clients can use the CURRENT-VALUE (or DYNAMIC-CURRENT-VALUE) function at the same time for a given sequence, it is not safe to use this kind of construct:

table.field = CURRENT-VALUE(SomeSequence). /*use current sequence value - multiple clients could get the same value before the sequence is incremented on the next line or further in the program*/
NEXT-VALUE(SomeSequence). /*increment the sequence*/

If two clients call this code at the same time, the following situation could occur (let's say the current-value of the sequence is 123):
Time = X - Client A get current-value = 123
Time = X + 1 - Client B get current-value = 123
Time = X + 2 - Client A asks DB to increment the sequence (it is now 124)
Time = X + 3 - Client B asks DB to increment the sequence (it is now 125)

But Progress guarantees that each call to NEXT-VALUE on a same sequence returns a new incremented value (calls to NEXT-VALUE are probably queued FIFO on the DB), so the good construct would simply be:

table.field = NEXT-VALUE(SomeSequence).

The new rule should give a warning when CURRENT-VALUE / DYNAMIC-CURRENT-VALUE is assigned to a table field.