Consultor Eletrônico



Kbase P183313: FIND finds record with unexpected sequence number
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/21/2011
Status: Verified

SYMPTOM(s):

FIND finds record with unexpected sequence number

FIND FIRST finds sequence number one less than the value requested

Problem statement is similar to:

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

Problem is intermittent

FACT(s) (Environment):

Sequence numbers are not approaching the maximum integer value
HP-UX
OpenEdge 10.1C

CAUSE:

The application code and a database trigger were both using the same sequence. As a result of the particular logic used, not every consecutive number in the sequence was represented in the database (i. e. there were 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, and processed the record that was already in the record buffer.

FIX:

When values from the same sequence are used at multiple points in the application, use caution when making assumptions about how the sequence numbers were 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.