Skip to main content

Sample.CustomResultSet

class Sample.CustomResultSet extends %SQL.CustomResultSet

This class is an example of subclassing %SQL.CustomResultSet. Custom result sets are similar to queries with TYPE = %Library.Query. Subclassing %SQL.CustomResultSet has a few advantages over custom queries. Result sets are somewhat more efficient when interacting with the server. The metadata for a result set is constructed from the class definition so there is never a need for ROWSPEC. Also, result sets provide a more OO interface. The result set created by this class contains rows (the number of rows specified at instantiation) of randomly generated data. When subclassing %SQL.CustomResultSet, there are a few steps that you must follow in order to produce a working result set. 1. Define properties that correspond to each column in the result row. 2. Define private properties that you need to maintain the current state of the result set. 3. Override and implement %OpenCursor. In this method you will initialize the result iterator and prepare the data for return. Report any errors encountered during execution by setting %SQLCODE and %Message. 4. Override and implement %Next. In this method you will retrieve the next row. If the end of the result set is reached then return 0. Otherwise, set the row properties to the appropriate value and return 1. 5. Override and implement %CloseCursor. This is only necessary if you need to perform some clean up. If you wish to instantiate your custom result set class and return it to a caller then you must implement an SQL routine (aka, "stored procedure"). This class includes an SQL routine 'CustomResult'. Instances of %SQL.IResultSet are not meant to be "reused" meaning that a result set class expects to be instantiated, the rows iterated over, and then destructed.

Property Inventory

Method Inventory

Parameters

parameter %statementmetadata;
parameter %statementmetadata0;
parameter %statementmetadataext;
parameter %statementobjects;

Properties

property City as %String;
Property methods: CityDisplayToLogical(), CityGet(), CityIsValid(), CityLogicalToDisplay(), CityLogicalToOdbc(), CityNormalize(), CitySet()
property ID as %Integer;
Property methods: IDDisplayToLogical(), IDGet(), IDIsValid(), IDLogicalToDisplay(), IDNormalize(), IDSet()
property Name as %String;
Property methods: NameDisplayToLogical(), NameGet(), NameIsValid(), NameLogicalToDisplay(), NameLogicalToOdbc(), NameNormalize(), NameSet()
property Spouse as Sample.Person;
Property methods: SpouseGet(), SpouseGetObject(), SpouseGetObjectId(), SpouseGetSwizzled(), SpouseIsValid(), SpouseNewObject(), SpouseSet(), SpouseSetObject(), SpouseSetObjectId(), SpouseUnSwizzle()
property State as %String;
Property methods: StateDisplayToLogical(), StateGet(), StateIsValid(), StateLogicalToDisplay(), StateLogicalToOdbc(), StateNormalize(), StateSet()
property Street as %String;
Property methods: StreetDisplayToLogical(), StreetGet(), StreetIsValid(), StreetLogicalToDisplay(), StreetLogicalToOdbc(), StreetNormalize(), StreetSet()

Methods

method %CloseCursor() as %Status
Clean up on destruct
method %Next(ByRef sc As %Library.Status) as %Library.Integer
Advance the result set cursor to the next row. Returns 0 if the cursor is at the end of the result set.
method %OpenCursor(rowCount As %Integer = 100) as %Library.Status
%OpenCursor() is used to initialize the cursor for iterating over the result set. Define formal arguments if needed. They will be automatically managed. If you need to access these argument values during the %OpenCursor/%Next/%CloseCursor cycle then simply define private properties as needed.
classmethod CustomResult(pRowcount As %Integer = 100) as %Status
Projected as the stored procedure: CustomResult
This is a stored procedure that returns an instance of Sample.CustomResultSet to the caller. This procedure could also declare input, input-output, output and return value parameters.

Inherited Members

Inherited Properties

Inherited Methods

FeedbackOpens in a new tab