Home > Class Reference > ENSLIB namespace > %Library.ScrollableResultSet

%Library.ScrollableResultSet

class %Library.ScrollableResultSet extends %Library.ResultSet

This provides a scrollable resultset object that can also be saved and loaded It works by running the entire query when the first item of data is requested and storing the results in a global. Then you can move around the results by setting the CurrRow and you may also call Previous() as well as the standard Next(). In addition you may save this resultset and then load it potentially in a different process at a later date and continue reading from it, for example:
 Set results=##class(%ScrollableResultSet).%New("Classname:QueryName")
  Do results.Execute()
  Do results.Next()
  Write results.Data("fieldname")
  Do results.%Save()
  Set id=results.%Id()
  Kill results
  Set results=##class(%ScrollableResultSet).%OpenId(id)
  Do results.Next()
  Write results.Data("fieldname")
  
Note that if you open a %ScrollableResultSet and do not call %Save on it then when you close this object the data stored in the global will be removed and so you will not be able to open this resultset again. So if you open a scrollable resultset and you wish to use this again call %Save on it, but you must always make sure that when you are finished with it you do not call %Save so the temporary global used is cleaned up when you are done. Alterntively you can call %DeleteId passing the id to remove the saved data.

There is also a Count() to find the total number of entries in this resultset. This will not work if running with a query against a remote linked table which returns stream data for a column because the remote linked table returns the stream as an oref and this class does not support persisting this oref.

Property Inventory (Including Private)

Method Inventory (Including Private)

Properties (Including Private)

property CurrRow as %Integer;
Number of current row in the temp table, you can set this property to move to a new location and also use this to check the current position. If you specify a value that is out of bounds then the row will not be moved. The first row is at CurrRow=1, so it is 1 based and not 0 based.
Property methods: CurrRowDisplayToLogical(), CurrRowGet(), CurrRowIsValid(), CurrRowLogicalToDisplay(), CurrRowNormalize(), CurrRowSet()
property IsSaved as %Boolean [ Private , InitialExpression = 0 ];
If true, the temp table has been saved and should not be automatically deleted.
Property methods: IsSavedDisplayToLogical(), IsSavedGet(), IsSavedIsValid(), IsSavedLogicalToDisplay(), IsSavedNormalize(), IsSavedSet()
property MaxRows as %Integer [ InitialExpression = 0 ];
This determines how many rows this query will load, the default '0' will load all the results, if you set it to 10,000 then it will only load the first 10,000 rows, which will mean you can not access any data beyond the 10,000th element. Also the actual stopping point may be slightly larger than MaxRows because of the way the data is imported, but it will be around this figure.
Property methods: MaxRowsDisplayToLogical(), MaxRowsGet(), MaxRowsIsValid(), MaxRowsLogicalToDisplay(), MaxRowsNormalize(), MaxRowsSet()
property TempIndex as %Integer [ Private ];
Index into temp global used to hold results
Property methods: TempIndexDisplayToLogical(), TempIndexGet(), TempIndexIsValid(), TempIndexLogicalToDisplay(), TempIndexNormalize(), TempIndexSet()

Methods (Including Private)

classmethod %DeleteId(id As %String, concurrency As %Integer = -1) as %Status
final method %Id() as %String
private method %OnClose() as %Status
Inherited description: This callback method is invoked by the %Close() method to provide notification that the current object is being closed.

The return value of this method is ignored.

classmethod %OpenId(id As %String, concurrency As %Integer = -1, ByRef sc As %Status = $$$OK) as %ObjectHandle
method %Save() as %Status
method Count() as %Integer
Returns the number of rows contained in this ResultSet.
method CurrRowSet(val As %String) as %Status
method GetObject() as %RegisteredObject
Inherited description: If this query contains an object Id then this method opens an object with this Id and returns the object reference. Otherwise it returns a null object reference.
method Load(id As %String) as %Status
Advance the result set cursor to the next row. Returns 0 if the cursor is at the end of the result set.
private method PopulateData() as %Status
Executes the current query.

The arguments p1... supply the value of any parameters the query may have.

Advance the result set cursor to the previous row. Returns 0 if the cursor is at the end of the result set.

Inherited Members

Inherited Properties (Including Private)

Inherited Methods (Including Private)