AddRecordsetNew (Recordset function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Recordset:AddRecordsetNew subtitle}}
{{Template:Recordset:AddRecordsetNew subtitle}}


<var>AddRecordsetNew</var> adds a <var>Recordset</var> object's records to the records in an existing
<var>AddRecordsetNew</var> combines a <var>Recordset</var> object's records with the records in a second
<var>Recordset</var> object, and produces a new <var>Recordset</var> object containing the combined
<var>Recordset</var> object, producing a new <var>Recordset</var> object containing the combined
records.
records.
It does the same processing as <var>[[AddRecordset (Recordset subroutine)|AddRecordset]]</var>
It does the same processing as <var>[[AddRecordset (Recordset subroutine)|AddRecordset]]</var>
Line 10: Line 10:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%target</th>
<tr><th>%outRecordset</th>
<td>The <var>Recordset</var> object variable created by this method.
<td>The <var>Recordset</var> object created by this method.
</td></tr>
</td></tr>
<tr><th>%rs</th>
<tr><th>recordset</th>
<td>A non-null <var>Recordset</var> object, which must have the same file context as ''%target''.
<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>recordsetObject</th>
<tr><th>inRecordset2</th>
<td>A non-null <var>Recordset</var> object, which must have the same file context as ''target'' and ''%rs''.
<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>
<li>The <var>AddRecordsetNew</var> method is only available in <var class="product">Sirius Mods</var> 7.1 and later.
<li>The <var>AddRecordsetNew</var> method is only available in <var class="product">Sirius Mods</var> 7.1 and later.
<li>The <var>LockStrength</var> and <var>LoopLockStrength</var> of the output <var>Recordset</var> object is
<li>The <var>LockStrength</var> and <var>LoopLockStrength</var> of the output <var>Recordset</var> object (<var class="term">%outRecordset</var>) is
the same as that of the method object (%rs).
the same as that of the method object (<var class="term">recordset</var>).
<li>The lock strength of the <var>Recordset</var> object being added to the method object
<li>The lock strength of <var class="term">inRecordset2</var> must be greater than or equal to the lock strength of the method object <var class="term">recordset</var>.
must be greater than or equal to the lock strength of the set being added to.


Consequently, <var>AddRecordset</var> will not require any new locks &amp;amp;mdash;
Consequently, <var>AddRecordset</var> will not require any new locks &mdash;
any records being added must already be locked by the user at an equal
all records being combined must already be locked by the user at an equal
or greater strength than the target.
or greater strength than lock strength of the resulting <var class="term">outRecordset</var>.
Therefore, this method will never cause a record locking conflict.
Therefore, this method will never cause a record locking conflict.
Within a <var>Recordset</var>, all records are always locked at the same strength (the
Within a <var>Recordset</var>, all records are always locked at the same strength (the
Line 38: Line 38:
Any violation of them results in request cancellation.
Any violation of them results in request cancellation.
<ul>
<ul>
<li>To a <var>Recordset</var> locked at exclusive level, you may add only records that are
<li>To a method object <var class="term">recordset</var> locked at exclusive level, you may combine only records that are
locked at exclusive level.
locked at exclusive level.
<li>To a <var>Recordset</var> locked at share level, you may add records
<li>To a method object <var class="term">recordset</var> locked at share level, you may combine records
locked at exclusive level or share level.
locked at exclusive level or share level.
<li>To an unlocked <var>Recordset</var> you may add records locked at any strength
<li>To an unlocked method object <var class="term">recordset</var> you may combine records locked at any strength
(exclusive, share, none).
(exclusive, share, none).
</ul>
</ul>
<li>If the <var>Recordset</var> object parameter of <var>AddRecordset</var> is null, the request is
<li>If the <var class="term">inRecordset2</var> argument of <var>AddRecordset</var> is null, the request is
cancelled.
cancelled.
<li>The <var>AddRecordsetNew</var> method can be thought of as a <var>Recordset</var> OR operation;
<li>The <var>AddRecordsetNew</var> method can be thought of as a <var>Recordset</var> OR operation;
Line 51: Line 51:
can be thought of as an AND; and
can be thought of as an AND; and
<var>[[RemoveRecordsetNew (Recordset function)|RemoveRecordsetNew]]</var>
<var>[[RemoveRecordsetNew (Recordset function)|RemoveRecordsetNew]]</var>
as a NOT.
as subtraction.


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 such an OR, as shown
you can use the basic methods to achieve an exclusive OR, as shown
in <var>[[RemoveRecordsetNew (Recordset function)#Examples|"Examples"]]</var>.
in the [[RemoveRecordsetNew (Recordset function)#Examples|"Examples"]] section of <var>RemoveRecordsetNew</var>.
</ul>
</ul>
==Example==
==Example==


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