Editar

Compartilhar via


ReadState Property

Version: Available or changed with runtime version 1.0.

Specifies which records are read and how they are locked when a query is executed.

Applies to

  • Query

Property value

Value Available or changed with Description
ReadUncommitted runtime version 1.0 Reads all data, regardless of whether it has been committed to the database. This means that the query can read data from table rows that have been modified by another running transaction, but have not yet been committed.

This mode is sometimes referred to as a dirty read. For those familiar with SQL, this translates to reading the data with ‘Read Uncommitted’.

No additional locks are placed on the read data. Because the query does not lock the rows it reads, other transactions can also read, modify, and delete the same data as the query.

Setting the property to ReadUncommitted can improve performance compared to ReadShared and ReadExclusive. However, the query can read data that potentially is rolled back or changed by another transaction when the query is running.
ReadShared runtime version 1.0 Reads only data that has been committed to the database.

Share locks are placed on all read data, which prevents it from being modified or deleted by other transactions. The locks are held until the current transaction is committed. It is possible for other transactions to read the data. Note: The Transaction Type of the transaction within which the query is running is not affected.

If you are familiar with SQL, this mode translates to reading the data with Repeatable Read.
ReadExclusive runtime version 1.0 Reads only data that has been committed to the database.

Update locks are placed on all read data, which prevents it from being modified or deleted by other transactions. It is possible for other transactions to read the data depending on their transaction types. Note: The Transaction Type of the transaction within which the query is running is not affected.

If you are familiar with SQL, this mode translates to reading the data with UpdLocks.

Remarks

Committed data is data that is saved to the database when a transaction is completed.

The ReadState property will overrule the current transaction type of the data as set by a CurrentTransactionType Method (Database) call in the AL code because queries ignore the CurrentTransactionType method call.

Each query will use the specified ReadState regardless of other queries that have already been executed. This means that you can read uncommitted data and committed data from the same tables in the same transaction. However, the strictest lock placed on a row will remain until the transaction is committed.

Properties