Salesforce

FIND finds record with unexpected sequence number

« Go Back

Information

 
TitleFIND finds record with unexpected sequence number
URL NameP183313
Article Number000132776
EnvironmentProduct: OpenEdge
Version: All supported versions
OS: All supported platforms
Other: Sequence
Question/Problem Description
FIND returns a record with an unexpected Sequence Number in the field
FIND FIRST finds a Sequence Number one less than the value requested
There are times when the Sequence Number is wrong followed by periods when they are correct
Sometimes re-trying the transaction returns the correct Sequence Number in the field

Problem statement is similar to:

FIND FIRST Customer NO-LOCK WHERE Customer.CustNum = cMyCustNum NO-ERROR.


 
Steps to Reproduce
Clarifying Information
Sequence numbers are not approaching the maximum integer value
Error Message
Defect Number
Enhancement Number
Cause
The application code and a database trigger are both using the same Sequence.

As a result of the particular logic used, not every consecutive number in the sequence is represented in the database (i. e. there are gaps in the sequence).
When a record with a "missing" sequence number was requested, the FIND statement failed. The application code did not account for this condition and processed the record that was already in the record buffer.
Resolution
When values from the same Sequence are used at multiple points in the application, use caution when making assumptions about how sequence numbers are assigned to records. To handle gaps in the sequence, examine the properties of the ERROR-STATUS handle after the FIND statement in order to  identify cases when a record cannot be found.

For example:
    
FIND FIRST Customer NO-LOCK WHERE Customer.CustNum = cMyCustNum NO-ERROR.

IF NOT AVAILABLE(Customer) THEN
DO:
    /* Error handling code */
END.
Workaround
Notes
Keyword Phrase
Last Modified Date2/1/2018 8:51 AM

Powered by