RecordLockingConflict class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (edits, tags and links)
m (I think it's a little clearer this way)
Line 1: Line 1:
<!-- RecordLockingConflict class -->
<!-- RecordLockingConflict class -->
The <var>RecordLockingConflict</var> exception class catches record locking conflict errors thrown by file object operations; that is from methods in the <var>[[File_classes|file classes]]</var> (<var>[[Record_class|Record]]</var>, <var>[[Recordset_class|Recordset]]</var>, <var>[[SortedRecordset_class|SortedRecordset]]</var>, and <var>[[RecordsetCursor_class|RecordsetCursor]]</var>).
The <var>RecordLockingConflict</var> exception class catches record locking conflict errors thrown by file object operations; that is from methods in the <var>[[File_classes|file]]</var> (ie: <var>[[Record_class|Record]]</var>, <var>[[Recordset_class|Recordset]]</var>, <var>[[SortedRecordset_class|SortedRecordset]]</var>, and <var>[[RecordsetCursor_class|RecordsetCursor]]</var>) classes.
   
   
An exception is thrown only if there is a Catcher for the exception.
An exception is thrown only if there is a Catcher for the exception.

Revision as of 06:49, 23 April 2011

The RecordLockingConflict exception class catches record locking conflict errors thrown by file object operations; that is from methods in the file (ie: Record, Recordset, SortedRecordset, and RecordsetCursor) classes.

An exception is thrown only if there is a Catcher for the exception.

There is no distinction between a Find conflict and a record locking conflict. For example, you can use the following:

try fd to %foo ... end find catch recordLockingConflict ... end try

And you can also use:

try %rec = new(%recnum, exclusive) for record %rec ... end for catch recordLockingConflict ... end try

You can even catch record locking conflicts caused by LoopLockStrength promotions during a loop:

%rec = new(%recnum, none, loopLockStrength=share) ... try for record %rec ... end for catch recordLockingConflict ... end try

Or as in the following:

%curser = new(%recset, loopLockStrength=none) ... try for record at cursor %curser ... end for catch recordLockingConflict .. end try

Or as in this example:

fdwol to %recset = new(loopLockStrength=exclusive) ... end find ... try for each record in %recset ... end for catch recordLockingConflict ... end try

In the latter example, note that any iteration of the For loop can throw an exception, and there is no way of picking up where you left off (at the next record, say) if you get a RecordLockingConflict exception in such a case. So, unless you always want to lose the whole loop on a record locking conflict, such a case is almost always better structured with a cursor on the recordset and with Try around the For Record At Cursor loop:

fdwol to %recset = new(loopLockStrength=exclusive) ... end find ... %curser = new(%recset, loopLockStrength=exclusive) repeat while %curser:state eq hasRecord try for record at cursor %curser ... end for catch recordLockingConflict ... end try %curser:next end repeat

Note: that the For statement can be on the same line as the Try, or it can be inside the Try block.

The methods in this class are listed at "List of RecordLockingConflict methods".