AddRecordsetNew (Recordset function): Difference between revisions
m (1 revision) |
m (→Example) |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:Recordset:AddRecordsetNew subtitle}} | |||
<var>AddRecordsetNew</var> | <var>AddRecordsetNew</var> combines a <var>Recordset</var> object's records with the records in a second | ||
<var>Recordset</var> object, | <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> | ||
but produces a new output <var>Recordset</var> and leaves the two input <var>Recordsets</var> unmodified. | but produces a new output <var>Recordset</var> and leaves the two input <var>Recordsets</var> unmodified. | ||
==Syntax== | ==Syntax== | ||
{{Template:Recordset:AddRecordsetNew syntax}} | |||
===Syntax terms=== | |||
===Syntax | |||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%outRecordset</th> | ||
<td>The <var>Recordset</var> object | <td>The <var>Recordset</var> object created by this method. | ||
</td></tr> | </td></tr> | ||
<tr><th> | <tr><th>recordset</th> | ||
<td>A non-null <var>Recordset</var> object, which must have the same file context as | <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> | <tr><th>inRecordset2</th> | ||
<td>A non-null <var>Recordset</var> object, which must have the same file context as | <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 | |||
==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 ( | the same as that of the method object (<var class="term">recordset</var>). | ||
<li>The lock strength of | <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 | |||
Consequently, <var>AddRecordset</var> will not require any new locks — | Consequently, <var>AddRecordset</var> will not require any new locks — | ||
all records being combined must already be locked by the user at an equal | |||
or greater strength than the | 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 43: | Line 38: | ||
Any violation of them results in request cancellation. | Any violation of them results in request cancellation. | ||
<ul> | <ul> | ||
<li>To a <var> | <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> | <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> | <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> | <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 56: | 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 | 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 | you can use the basic methods to achieve an exclusive OR, as shown | ||
in | 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 | |||
%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) | |||
</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== | |||
<ul> | |||
<li><var>[[AddRecord (Recordset subroutine)|AddRecord]]</var> | |||
<li><var>[[AddRecordset (Recordset subroutine)|AddRecordset]]</var> | |||
</ul> | |||
{{Template:Recordset:AddRecordsetNew footer}} |
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.