RecordLockingConflict class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 17: Line 17:
   
   
And you can also use:
And you can also use:
<p class="code"> [[try]]
<p class="code"> try
     %rec = [[New_(Record_constructor)|new]](%recnum, exclusive)
     %rec = [[New_(Record_constructor)|new]](%recnum, exclusive)
     for record %rec
     for record %rec
         ...
         ...
     end for
     end for
  [[catch]] recordLockingConflict
  catch recordLockingConflict
     ...
     ...
  end try
  end try
Line 30: Line 30:
<p class="code"> %rec = new(%recnum, none, loopLockStrength=share)
<p class="code"> %rec = new(%recnum, none, loopLockStrength=share)
   ...
   ...
  [[try]] for record %rec
  try for record %rec
     ...
     ...
     end for
     end for
  [[catch]] recordLockingConflict
  catch recordLockingConflict
     ...
     ...
  end try
  end try
Line 41: Line 41:
<p class="code"> %curser = new(%recset, loopLockStrength=none)
<p class="code"> %curser = new(%recset, loopLockStrength=none)
   ...
   ...
  [[try]]
  try
     for record at cursor %curser
     for record at cursor %curser
       ...
       ...
     end for
     end for
  [[catch]] recordLockingConflict
  catch recordLockingConflict
     ..
     ..
  end try
  end try
Line 55: Line 55:
  end find
  end find
   ...
   ...
  [[try]] for each record in %recset
  try for each record in %recset
       ...
       ...
     end for
     end for
  [[catch]] recordLockingConflict
  catch recordLockingConflict
     ...
     ...
  end try
  end try
Line 70: Line 70:
  %curser = new(%recset, loopLockStrength=exclusive)
  %curser = new(%recset, loopLockStrength=exclusive)
  repeat while %curser:state eq hasRecord
  repeat while %curser:state eq hasRecord
     [[try]] for record at cursor %curser
     try for record at cursor %curser
       ...
       ...
     end for
     end for
     [[catch]] recordLockingConflict
     catch recordLockingConflict
       ...
       ...
     end try
     end try
     %curser:[[next]]
     %curser:next
  end repeat
  end repeat
</p>
</p>
   
   
<b><i>Note:</i></b> that the For statement can be on the same line as the <var>Try</var>, or it can be inside the <var>Try</var> block.
<b>Note:</b> The <var>For</var> statement can be on the same line as the <var>Try</var>, or it can be inside the <var>Try</var> block.




Line 92: Line 92:
<li>[[RecordLockingConflict methods syntax|"RecordLockingConflict methods syntax"]] is a single page that contains the syntax diagrams of all the methods in the class.
<li>[[RecordLockingConflict methods syntax|"RecordLockingConflict methods syntax"]] is a single page that contains the syntax diagrams of all the methods in the class.
</ul>
</ul>
<h2>Filename property</h2>
{{Template:RecordLockingConflict:Filename subtitle}}
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> property returns a <var>[[Longstrings|Longstring]]</var> that contains the name of the file in which the last record locking conflict occurred.
<h4>Syntax</h4>
{{Template:RecordLockingConflict:Filename syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%string</th>
<td>A <var>longstring</var> to receive the file name.
</td></tr>
<tr><th>recordLockingConflict</th>
<td>A reference to an instance of a <var>[[RecordLockingConflict_class|RecordLockingConflict]]</var> object.
</td></tr></table>




<h2>New constructor</h2>
<h2>New constructor</h2>
{{Template:RecordLockingConflict:New subtitle}}
This constructor generates an instance of an <var>[[RecordLockingConflict_class|RecordLockingConflict]]</var> exception. As shown in the syntax that follows, the <var>New</var> method arguments set the values of the class properties having the corresponding names.  Each argument to <var>New</var> sets the value of the corresponding property of the newly constructed <var>RecordLockingConflict</var> object.
<h4>Syntax</h4>
{{Template:RecordLockingConflict:New syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%recordLockingConflict</th>
<td>A reference to an instance of a <var>RecordLockingConflict</var> object.
</td></tr>
<tr><th>%(RecordLockingConflict)</th><td>The class name in parentheses denotes a shared method.</td></tr>
<tr><th><var>Filename</var></th>
<td>This [[Methods#Named parameters|name required]] parameter specifies the <var>[[Longstrings|Longstring]]</var> value (''filename'') to be assigned to the object's <var>[[Filename_(RecordLockingConflict_property)|Filename]]</var> property. Its default value is a null string.
</td></tr>
<tr><th><var>RecordNumber</var></th>
<td>This name required parameter specifies the numeric value (''recnum'') to be assigned to the object's <var>[[RecordNumber_(RecordLockingConflict_property)|RecordNumber]]</var> property. Its default value is 0.
</td></tr>
<tr><th><var>UserNumber</var></th>
<td>This name required parameter specifies the numeric value (''usernum'') to be assigned to the exception object's <var>[[UserID_(RecordLockingConflict_property)|UserNumber]]</var> property. Its default value is 0.
</td></tr>
<tr><th><var>UserID</var></th>
<td>This name required parameter specifies the longstring value (''userid'') to be assigned to the object's <var>[[UserNumber_(RecordLockingConflict_property)|UserID]]</var> property. Its default value is a null string.
</td></tr>
</table>
<h2>RecordNumber property</h2>
{{Template:RecordLockingConflict:RecordNumber subtitle}}
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> property returns the numeric value of the <var class="product">Model 204</var> internal record number of the record that has the conflict.
<h4>Syntax</h4>
{{Template:RecordLockingConflict:RecordNumber syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%number</th>
<td>A numeric variable to receive the record number.
</td></tr>
<tr><th>recordLockingConflict</th>
<td>A reference to an instance of a <var>[[RecordLockingConflict_class|RecordLockingConflict]]</var> object.
</td></tr></table>
<h4>Example</h4>
The following example shows all the properties of the <var>RecordLockingConflict</var> class.  While the standard record locking conflict information is available for retrieval via the <var class="Product">User Language</var> functions $rlcfile, $rlcrec, $rlcuid, and $rlcusr, that information is also set in the exception object and retrievable via that object:
<p class="code"> %rlc  is object RecordLockingConflict
  ...
%rec = new(%recnum, none, loopLockStrength=share)
  ...
[[try]] for record %rec
    ...
    end for
[[catch]] recordLockingConflict to %rlc
    [[Audittext|auditText]] Conflict on record {%rlc:recordNumber}    -
      in file {%rlc:filename}
    auditText Conflicting user was userid {%rlc:userid}, -
      with user number:{%rlc:userNumber}
end try
</p>
<h2>UserID property</h2>
{{Template:RecordLockingConflict:UserID subtitle}}
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> property returns the <var class="product">Model 204</var> userid (login name) of the user that has the conflict.
<h4>Syntax</h4>
{{Template:RecordLockingConflict:UserID syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%userid</th>
<td>A <var>[[Longstrings|longstring]]</var> to receive the userid value.
</td></tr>
<tr><th>recordLockingConflict</th>
<td>A reference to an instance of a <var>[[RecordLockingConflict_class|RecordLockingConflict]]</var> object.
</td></tr></table>
<h2>UserNumber property</h2>
{{Template:RecordLockingConflict:UserNumber subtitle}}
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> property returns the user number (unique per session) of the user that has the conflict.
<h4>Syntax</h4>
{{Template:RecordLockingConflict:UserNumber syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%number</th>
<td>A numeric variable to receive the user number.
</td></tr>
<tr><th>recordLockingConflict</th>
<td>A reference to an instance of a <var>[[RecordLockingConflict_class|RecordLockingConflict]]</var> object.
</td></tr></table>
[[Category:System exception classes]]
[[Category:System exception classes]]

Revision as of 19:27, 10 May 2011


The RecordLockingConflict exception class catches record locking conflict errors thrown by file object operations; that is from methods in the file (that is: 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: The For statement can be on the same line as the Try, or it can be inside the Try block.


The RecordLockingConflict methods

The following are the available RecordLockingConflict class methods.

MethodDescription
ConflictTimeMillisecondsTime that the conflict occurred
ConflictingLockStrengthLock strength of conflicting lock
ConflictingRecordLockTypeLock type of conflicting lock
CopyCopy the RecordLockingConflict object
DeepCopyDeep copy the RecordLockingConflict object
FilenameName of the file in which last record locking conflict occurred
LockTimeMillisecondsTime that the conflicting record was locked
LockingUserNumberUser number of the user that locked the conflicting record
NewCreate a new RecordLockingConflict object
NewFromLastConflictCreate object from current conflict information
RecordNumberRecord number of the record that has the conflict
UserIDUser ID (login name) of the user that has the conflict
UserNumberUser number of the user that has the conflict

The methods in the class are described in the subsections that follow. In addition:


Filename property

Name of the file in which last record locking conflict occurred (RecordLockingConflict class)

This ReadOnly property returns a Longstring that contains the name of the file in which the last record locking conflict occurred.

Syntax

%string = recordLockingConflict:Filename

Syntax terms

%string A longstring to receive the file name.
recordLockingConflict A reference to an instance of a RecordLockingConflict object.


New constructor

Create a new RecordLockingConflict object (RecordLockingConflict class)

This constructor generates an instance of an RecordLockingConflict exception. As shown in the syntax that follows, the New method arguments set the values of the class properties having the corresponding names. Each argument to New sets the value of the corresponding property of the newly constructed RecordLockingConflict object.

Syntax

%recordLockingConflict = [%(RecordLockingConflict):]New( Filename= string, - RecordNumber= number, - UserNumber= number, - UserID= string, - [LockingUserNumber= number], - [LockTimeMilliseconds= number], - [ConflictTimeMilliseconds= number], - [ConflictingLockStrength= lockStrength], - [ConflictingRecordLockType= recordLockType])

Syntax terms

%recordLockingConflict A reference to an instance of a RecordLockingConflict object.
%(RecordLockingConflict)The class name in parentheses denotes a shared method.
Filename This name required parameter specifies the Longstring value (filename) to be assigned to the object's Filename property. Its default value is a null string.
RecordNumber This name required parameter specifies the numeric value (recnum) to be assigned to the object's RecordNumber property. Its default value is 0.
UserNumber This name required parameter specifies the numeric value (usernum) to be assigned to the exception object's UserNumber property. Its default value is 0.
UserID This name required parameter specifies the longstring value (userid) to be assigned to the object's UserID property. Its default value is a null string.


RecordNumber property

Record number of the record that has the conflict (RecordLockingConflict class) This ReadOnly property returns the numeric value of the Model 204 internal record number of the record that has the conflict.


Syntax

%number = recordLockingConflict:RecordNumber

Syntax terms

%number A numeric variable to receive the record number.
recordLockingConflict A reference to an instance of a RecordLockingConflict object.

Example

The following example shows all the properties of the RecordLockingConflict class. While the standard record locking conflict information is available for retrieval via the User Language functions $rlcfile, $rlcrec, $rlcuid, and $rlcusr, that information is also set in the exception object and retrievable via that object:

%rlc is object RecordLockingConflict ... %rec = new(%recnum, none, loopLockStrength=share) ... try for record %rec ... end for catch recordLockingConflict to %rlc auditText Conflict on record {%rlc:recordNumber} - in file {%rlc:filename} auditText Conflicting user was userid {%rlc:userid}, - with user number:{%rlc:userNumber} end try


UserID property

User ID (login name) of the user that has the conflict (RecordLockingConflict class) This ReadOnly property returns the Model 204 userid (login name) of the user that has the conflict.

Syntax

%string = recordLockingConflict:UserID

Syntax terms

%userid A longstring to receive the userid value.
recordLockingConflict A reference to an instance of a RecordLockingConflict object.


UserNumber property

User number of the user that has the conflict (RecordLockingConflict class) This ReadOnly property returns the user number (unique per session) of the user that has the conflict.

Syntax

%number = recordLockingConflict:UserNumber

Syntax terms

%number A numeric variable to receive the user number.
recordLockingConflict A reference to an instance of a RecordLockingConflict object.