getSystemSequenceNumberNext
getSystemSequenceNumberNext(name: String): Integer64;
The getSystemSequenceNumberNext method of the System class increments the current value of the system-sequence-number specified by the name parameter and returns the new value. The range of numbers returned is 1 through Max_Integer64, unless the system sequence number has not been created when the method returns zero (0).
The sequence number should be initialized on system startup, by using the createSystemSequenceNumber method.
If the method returns Max_Integer64 for the specified system sequence number, all subsequent calls for that system sequence number raise a
Ensure that the initial value passed to the createSystemSequenceNumber method does not cause the getSystemSequenceNumberNext method to return an already used number.
If the getSystemSequenceNumberNext method returns zero (0), determine the highest number that has been assigned to an object stored in the database and call the createSystemSequenceNumber method passing that value.
If an object obtains a sequence number but the object is not persisted because the transaction is aborted, there will be a gap in the stored number sequence.
The following method returns the next available customer number, where the customer number is used as a key in an exclusive MemberKeyDictionary collection owned by a Company object.
getNextCustomerNumber(): Integer64; constants SSN_CustomerNumber :String = "MySchema::CustomerNumber"; vars nextNumber : Integer64; coy : Company; cust : Customer; begin nextNumber := system.getSystemSequenceNumberNext(SSN_CustomerNumber); if nextNumber = 0 then coy := Company.firstInstance(); if coy <> null then cust := coy.allCustomersByNumber.last(); if cust <> null then nextNumber := cust.number endif; endif; system.createSystemSequenceNumber(SSN_CustomerNumber, nextNumber); nextNumber := system.getSystemSequenceNumberNext(SSN_CustomerNumber); endif; return nextNumber; end;