AddRecordsetNew (Recordset function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 14: Line 14:
</td></tr>
</td></tr>
<tr><th>recordset</th>
<tr><th>recordset</th>
<td>A non-null <var>Recordset</var> object, which must have the same file context as <var class="term">outRecordset</var>.
<td>A non-null <var>Recordset</var> object, which must have the same file context as <var class="term">%outRecordset</var>.
</td></tr>
</td></tr>
<tr><th>inRecordset2</th>
<tr><th>inRecordset2</th>
<td>A non-null <var>Recordset</var> object, which must have the same file context as <var class="term">outRecordset</var> and <var class="term">recordset</var>.
<td>A non-null <var>Recordset</var> object, which must have the same file context as <var class="term">%outRecordset</var> and <var class="term">recordset</var>.


</td></tr></table>
</td></tr></table>
==Usage notes==
==Usage notes==
<ul>
<ul>
Line 54: Line 55:
No basic method is the analog of an exclusive OR operation, but
No basic method is the analog of an exclusive OR operation, but
you can use the basic methods to achieve an exclusive OR, as shown
you can use the basic methods to achieve an exclusive OR, as shown
in <var>[[RemoveRecordsetNew (Recordset function)#Examples|"RemoveRecordsetNew Examples"]]</var>.
in the [[RemoveRecordsetNew (Recordset function)#Examples|"Examples"]] section of <var>RemoveRecordsetNew</var>.
</ul>
</ul>


Line 61: Line 62:
In the following example, the result of one <var>Find</var> is combined with the
In the following example, the result of one <var>Find</var> is combined with the
result of another:
result of another:
<p class="code"> %review      is object recordSet in  file orders
<p class="code">%review      is object recordSet in  file orders
%pending    is object recordSet in  file orders
%pending    is object recordSet in  file orders
%both        is object recordSet in  file orders
%both        is object recordSet in  file orders


find records to %review
find records to %review
    status = 'REVIEW'
  status = 'REVIEW'
end find
end find


find records to %pending
find records to %pending
    status = 'PENDING'
  status = 'PENDING'
end find
end find


%both = %review:addRecordsetNew(%pending)
%both = %review:addRecordsetNew(%pending)
</p>
</p>
Of course, identical processing could be done with an
Of course, identical processing could be done with an <var>Or</var> in a <var>Find</var> statement.
<var>Or</var> in a <var>Find</var> statement.
 
==See also==
==See also==
<ul>
<ul>

Latest revision as of 22:20, 6 November 2012

Combine two RecordSets to produce a third (Recordset class)


AddRecordsetNew combines a Recordset object's records with the records in a second Recordset object, producing a new Recordset object containing the combined records. It does the same processing as AddRecordset but produces a new output Recordset and leaves the two input Recordsets unmodified.

Syntax

%outRecordset = recordset:AddRecordsetNew( inRecordset2)

Syntax terms

%outRecordset The Recordset object created by this method.
recordset A non-null Recordset object, which must have the same file context as %outRecordset.
inRecordset2 A non-null Recordset object, which must have the same file context as %outRecordset and recordset.

Usage notes

  • The AddRecordsetNew method is only available in Sirius Mods 7.1 and later.
  • The LockStrength and LoopLockStrength of the output Recordset object (%outRecordset) is the same as that of the method object (recordset).
  • The lock strength of inRecordset2 must be greater than or equal to the lock strength of the method object recordset. Consequently, AddRecordset will not require any new locks — all records being combined must already be locked by the user at an equal or greater strength than lock strength of the resulting outRecordset. Therefore, this method will never cause a record locking conflict. Within a Recordset, all records are always locked at the same strength (the lock strength with which the object was created). In summary, these locking rules are in effect. Any violation of them results in request cancellation.
    • To a method object recordset locked at exclusive level, you may combine only records that are locked at exclusive level.
    • To a method object recordset locked at share level, you may combine records locked at exclusive level or share level.
    • To an unlocked method object recordset you may combine records locked at any strength (exclusive, share, none).
  • If the inRecordset2 argument of AddRecordset is null, the request is cancelled.
  • The AddRecordsetNew method can be thought of as a Recordset OR operation; AndRecordsetNew can be thought of as an AND; and RemoveRecordsetNew as subtraction. No basic method is the analog of an exclusive OR operation, but you can use the basic methods to achieve an exclusive OR, as shown in the "Examples" section of RemoveRecordsetNew.

Example

In the following example, the result of one Find is combined with the result of another:

%review is object recordSet in file orders %pending is object recordSet in file orders %both is object recordSet in file orders find records to %review status = 'REVIEW' end find find records to %pending status = 'PENDING' end find %both = %review:addRecordsetNew(%pending)

Of course, identical processing could be done with an Or in a Find statement.

See also