VistaDB 6
VistaDB.DDA Namespace / IVistaDBTable Interface / SetScope Method / SetScope(IVistaDBRow,IVistaDBRow) Method
The row of key column values defining the lower bound before the first included row of the scope under the sort order of the ActiveIndex. The lowKey should first be initialized by calling InitTop() before setting column values to ensure an inclusive lower bound (or InitBottom() for an exclusive lower bound).
The row of key column values defining the upper bound after the last included row of the scope under the sort order of the ActiveIndex. The highKey should first be initialized by calling InitBottom() before setting column values to ensure an inclusive upper bound (or InitTop() for an exclusive upper bound).


In This Topic
    SetScope(IVistaDBRow,IVistaDBRow) Method
    In This Topic
    Set the scope for the table to constrain the range of rows under the ActiveIndex. After setting an ActiveIndex on the table (or null to use natural storage order) you can get copies from the CurrentKey property for row instances with the correct schema to use as the arguments.
    Syntax
    'Declaration
     
    
    Overloads Sub SetScope( _
       ByVal lowKey As IVistaDBRow, _
       ByVal highKey As IVistaDBRow _
    ) 
    'Usage
     
    
    Dim instance As IVistaDBTable
    Dim lowKey As IVistaDBRow
    Dim highKey As IVistaDBRow
     
    instance.SetScope(lowKey, highKey)

    Parameters

    lowKey
    The row of key column values defining the lower bound before the first included row of the scope under the sort order of the ActiveIndex. The lowKey should first be initialized by calling InitTop() before setting column values to ensure an inclusive lower bound (or InitBottom() for an exclusive lower bound).
    highKey
    The row of key column values defining the upper bound after the last included row of the scope under the sort order of the ActiveIndex. The highKey should first be initialized by calling InitBottom() before setting column values to ensure an inclusive upper bound (or InitTop() for an exclusive upper bound).
    Remarks

    Note that if either lowKey or highKey is passed as null reference the scope will be reset to the entire table as if ResetScope was called.

    If ActiveIndex is not set to null the active row order is sorted by the key column(s) of the specified index and then by the rows' unique RowId property value (to distinguish rows with the same key column values). If ActiveIndex is set to null the active row order is sorted directly by the rows' unique RowId property.

    After obtaining copies from the CurrentKey property you can build inclusive or exclusive bounds by initializing each row instance to the lowest (earliest) value (IVistaDBRow.InitTop) or highest (latest) value (IVistaDBRow.InitBottom) before setting the desired column values. For example, to set an inclusive lower bound first initialize the lowKey instance by calling InitTop() and then set the desired value for the first one or more columns--leaving any later columns in the key unchanged if desired. To set an exclusive lower bound, instead, first initizlie the lowKey instance by calling InitBottom() before setting the desired column values. For the highKey use the reverse: initialize the highKey by calling InitBottom() for an inclusive upper bound or by calling InitTop() for an exclusive upper bound. For the natural storage order (ActiveIndex = null) it is not necessary to call InitTop() or InitBottom(); the RowId values will automatically be adjusted to be inclusive bounds.

    For a single-column index this is straightforward as there is only one column value to set. A multi-column index can be used like a single-column index in this way by setting only the first column (after initialization with InitTop() or InitBottom()) and leaving the remaining columns unchanged. For the natural storage order (ActiveIndex set to null), after initialization with InitTop() or InitBottom() only set the RowId property in each key--which will then be an inclusive or exclusive bound as described above. Do not change the RowId property when setting a scope under other ActiveIndex values or the inclusive/exclusive bound behavior could be less predictable.

    For more advanced usage, constraining multiple columns can be performed in a scope on a multi-column index with the caveat that a column in the key should only be used if each column before it in the key is being constrained to a specific value in both the lowKey and highKey; the last column used (which may be any column in the key) can then constrain either a specific value or a range, and it is the inclusivity or exclusivity of this range which is determined by whether each key in the scope was initialized by InitTop() or InitBottom()--thus determining the remaining values in the key--as described above. Remember, the columns are not constrained independently but rather by the lower and upper bounds of the single scope within the overall sort order of the ActiveIndex--depending on where in the sort order the lowKey and highKey would each fall.

    Alternately, actual rows of the table copied from CurrentRow (or from CurrentKey) may be used as arguments without modification (with care not to get the order of the bounds reversed or the scope would be empty). Do not use InitTop() or InitBottom() on rows copied from CurrentRow rather than CurrentKey as it may not match the order of the ActiveIndex. The RowId values of the arguments will automatically be adjusted to be inclusive bounds if actual rows of the table are thus used.

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also