%SQL.CustomResultSet
abstract class %SQL.CustomResultSet extends %SQL.IResultSet
%SQL.CustomResultSet is the root class for custom result sets. You can extend this class to implement custom result sets that can be instantiated and returned as dynamic result sets by a stored procedure. Custom result sets are similar to queries with TYPE = %Library.Query. Subclassing %SQL.CustomResultSet has a few advantages over custom queries. Result sets are 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, %SQL.CustomResultSet defines a more object-oriented interface.
You can make custom result sets available to dynamic SQL by implementing a class method projected as a stored procedure. An example of a custom result set is available in the SAMPLES database. There is also an example of creating a stored procedure that returns an instance of a custom result set to the caller. Such a procedure can be invoked using the embedded or dynamic CALL statement.
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. If the property type is swizzleable then
any direct access to the property will trigger swizzling. %Get, %GetData and the various %Send methods will not
swizzle the object.
Note: Properties inherited from a system superclass are not considered to be part of the row.
2. Define any private properties needed to maintain the current state of the result set.
3. Override and implement %OpenCursor. Code in this method initializes the result iterator and prepares the data for return. It also reports any errors encountered during execution by setting %SQLCODE and %Message.
4. Override and implement %Next. Code in this method retrieves the next row and sets the properties corresponding to columns in the row to the appropriate value. If no row is found this method returns 0, otherwise it returns 1. This method must also set value of the %ROWCOUNT property.
5. Override and implement %CloseCursor. This is only necessary if you need to perform some clean up. %CloseCursor is called when the object is destructed.
Method Inventory
Parameters
Methods
If colname is not a valid column name, this method throws a error.
Inherited Members
Inherited Properties
- %CurrentResult
- %Message
- %Metadata
- %OutputColumnCount
- %PrivateTables
- %ROWCOUNT
- %ROWID
- %ResultColumnCount
- %SQLCODE
- %StatementType
- %StatementTypeName
Inherited Methods
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %Display()
- %DisplayFormatted()
- %Extends()
- %GetMetadata()
- %GetParameter()
- %IsA()
- %IsModified()
- %MoreResults()
- %New()
- %Next()
- %NextOutputValue()
- %NextResult()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %Print()
- %SerializeObject()
- %SetModified()
- %ValidateObject()
- Close()
- Fetch()
- FetchRows()
- GetInfo()
- GetODBCInfo()
- getSelectMode()