ROWID 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 ROWID, which is supported for OpenEdge and all other DataServer databases.
Note: The ROWID function corresponds to the ROWID attribute.This function replaces the RECID function for most applications. However, you must use the RECID function for maintaining schema objects (file and field relationships) in the ABL meta-schema files.
Syntax
record
The name of the record whose ROWID you want.To use the ROWID 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.ExampleYou 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 ROWID function puts the internal database identifier of that record in the
crowid
variable. If the user decides to update theCreditLimit
field, the procedure finds the record again using the value incrowid
. 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.
Notes
- Use the ROWID function to rapidly retrieve a previously identified record, even if that record has no unique index.
- The ROWID data type is a variable-length byte string capable of representing a record identifier for any DataServer database. However, the scope of a specific ROWID returned by the ROWID function depends on the DataServer and possibly the table within a database. The ROWID values for some DataServers change whenever the corresponding record is modified. For others, a ROWID value can change when a particular column in a table is modified. For more information on how different DataServers derive and work with ROWID values, see the OpenEdge DataServer Guides (OpenEdge Data Management: DataServer for Microsoft SQL Server, OpenEdge Data Management: DataServer for ODBC, and OpenEdge Data Management: DataServer for Oracle).
- You cannot return a ROWID for a view because view records do not have unique identifiers.
- You can compare ROWID values using the ABL relational operators (=, >, <, <>, >=, and <=), such as in the WHERE option of the Record phrase.
- You can use a ROWID value in a REPOSITION statement to specify the new position for a query cursor.
- If you want a called procedure to use the same record as a calling procedure, use the ROWID function to ensure that you are retrieving the same record. Use a SHARED ROWID variable or procedure parameter to communicate the ROWID 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 or buffer parameters.
- You can store a ROWID value in a work table, but not directly in a temp-table or database table. You can use the STRING function to convert a ROWID value to a character string, which you can store in a temporary or database table, and convert it back to a ROWID value using the TO-ROWID function.
- You do not have to explicitly check to see whether a record is AVAILABLE before using the ROWID function. The ROWID function returns the Unknown value (
?
) if a record cannot be accessed.This example checks the ROWID for each Customer record returned for a query to determine if another record exists to update. If no more records exist, the update loop (QuickFix) terminates.
See alsoDEFINE BUFFER statement, DEFINE VARIABLE statement, RECID function, Record phrase, REPOSITION statement, STRING function, TO-ROWID function
OpenEdge Release 10.2B
|