Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : RECID function
 

RECID function

Returns the unique internal identifier of the database record currently associated with the record buffer you name. This internal identifier has the data type RECID, a four-byte value that is supported by OpenEdge databases and some non-OpenEdge DataServers.
This function is supported for backward compatibility. For most applications, use the ROWID function, instead. For more information, see the ROWID function reference entry.

Syntax

RECID ( record )
record
The name of the record whose RECID you want.
To use the RECID function with a record in a table defined for multiple databases, you must qualify the record's table name with the database name. See the Record phrase reference entry for more information.

Example

You might decide that you do not want to lock a record until the user starts to update that record. In the example procedure, the FIND statement reads a Customer record without locking the record. The RECID function puts the internal database identifier of that record in the crecid variable. If the user decides to update the CreditLimit field, the procedure finds the record again using the value in crecid. The second FIND statement reads the record again, this time placing an EXCLUSIVE-LOCK on it. Because the record is first found with NO-LOCK, it is possible for the record to be updated by another user after the first FIND and before the second.
r-recid.p
DEFINE VARIABLE response AS LOGICAL NO-UNDO.
DEFINE VARIABLE crecid   AS RECID   NO-UNDO.

REPEAT:
  PROMPT-FOR Customer.CustNum.
  FIND Customer NO-LOCK USING Customer.CustNum.
  crecid = RECID(Customer).
  DISPLAY Customer.name.
  response = YES.
  UPDATE response LABEL "Update credit-limit ?".
  IF response THEN DO:
    FIND Customer WHERE RECID(Customer) = crecid EXCLUSIVE-LOCK.
    UPDATE Customer.CreditLimit.
  END.
END.

Notes

*Use the RECID function to rapidly retrieve a previously identified record, even if that record has no unique index.
*If you want a called procedure to use the same record as a calling procedure, use the RECID function to ensure that you are retrieving the same record. Use a SHARED variable to communicate the RECID of a record from one procedure to another. The second procedure can then find the same record. This is an alternative to using shared buffers.
*Avoid storing RECID values in database fields because those RECIDs will change if you dump and reload the database.
*You cannot use a RECID to identify the partition of a record in a partitioned table. Using a stored RECID to retrieve a record in a partitioned table will not work unless the record is in the initial composite partition. Use ROWID instead.
*You do not have to explicitly check to see whether a record is AVAILABLE before using the RECID function. The RECID function returns the Unknown value (?) if a record cannot be accessed.
This example displays a RECID only when a record can be accessed:
DISPLAY (IF AVAILABLE Customer THEN RECID(Customer) ELSE ?).
Directly reference RECID even if a record cannot be found:
FOR EACH Customer NO-LOCK:
DISPLAY Customer.CustNum.
END.
DISPLAY RECID(Customer).

See also

DEFINE BUFFER statement, DEFINE VARIABLE statement, Record phrase, ROWID function