7 The Oracle Data Provider : Using the ROWID Pseudo-Column

Using the ROWID Pseudo-Column
Oracle supports a pseudo-column called ROWID. ROWID can be listed as a column name in the Select list for any Oracle table. Although the column does not actually exist in the record, it represents the location of the record in the database. Only the Oracle server can assign the ROWID for each record. The Oracle data provider represents ROWID as an 18-character, base 64 string.
The OracleDbType enumeration has an entry for the ROWID type. Applications should use the OracleDbType.RowId type to describe a parameter associated with a ROWID column.
The fastest way for Oracle to locate a record is by specifying the ROWID in a Where clause. Consider using ROWIDs when configuring your application to work with the OracleDataAdapter object. By including ROWID in the Select list for the Select command, you can leverage it in your Where clause for your Update and Delete commands. If you are using the OracleCommandBuilder objects to generate your SQL statements for the OracleDataAdapter, you can also use the AddRowID method to have it automatically add ROWID to your Select statements. See “OracleCommand Class” for details on the AddRowID method.
In addition, the Oracle data provider has special support for getting ROWID back from an Insert statement. By adding a return value parameter to the Insert command’s parameter collection, the data provider can return the ROWID to the application.
To use this special feature, add a parameter with the following settings to the parameter collection of your Insert command:
For example:
insertCommand.Parameters.Add(":v1", OracleDbType.RowId, 18, "ROWID").Direction = ParameterDirection.ReturnValue;
NOTE: The return value parameter will not correspond to any parameter marker in the actual Insert command text. Although it can be placed anywhere in the collection, we recommend that you add the return value parameter to the end of the collection.
The OracleDataAdapter automatically sets the ROWID value when executing the Insert command with a properly configured return value parameter. This allows your application to change the newly inserted row in the OracleDataSet.