Results 1 to 3 of 3

Thread: Locking done by UpdateBatch method?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    97

    Locking done by UpdateBatch method?

    Quick question:

    For an ADODB record set, when you use the UpdateBatch method, does it attempt to lock the entire table or only the records in the record set? (Imagine you're doing a loop on the record set, updating records one by one, and when the loop ends you call the UpdateBatch method.)

    Thanks!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Locking done by UpdateBatch method?

    I think it uses something like exclusive locking.

    After the call, any failed updates can be found by inspecting the Recordset for the failed updates. You do that by setting .Filter = adFilterConflictingRecords and walking the Recordset for the failed records.

    As it says in the Fine Manual:

    If the attempt to transmit changes fails for any or all records because of a conflict with the underlying data (for example, a record has already been deleted by another user), the provider returns warnings to the Errors collection and a run-time error occurs. Use the Filter property (adFilterAffectedRecords) and the Status property to locate records with conflicts.

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,166

    Re: Locking done by UpdateBatch method?

    Which RDBMS do you issue this UpdateBatch against?

    Using MSSQL OLEDB provider there is no explicit locking specified in the generated T-SQL so locking depends only on current isolation level that the current outstanding transaction is at.

    This includes whether the DB is configured to use "snapshot isolation on (default) read commited" level. This setting turns read-commited isolation to snapshot isolation. Snapshot isolation prevents locks from happening at all i.e. readers keep on reading on last version of the data (snapshot) while the writers are updating outstanding uncommited transactions isolated in separate snapshots which get merged on COMMIT.

    Btw, this complete isolation can be problematic when two writers need to block each other so that their access to a table is sequential.

    Btw, snapshot isolation means that ADODB.Connection's Commit method might fail already on snapshot merge which has never happened before snapshot isolations were introduced.

    cheers,
    </wqw>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width