Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

%Library.AbstractResultSet

abstract class %Library.AbstractResultSet extends %Library.IResultSet

Abstract version of the resultset which specific implementations of result sets inherit from.

A result set is a type of result returned by executing either a SELECT statement or a CALL statement. Please refer to %SQL.Statement and %SQL.StatementResult for more information on how to prepare dynamic SQL statements and how to process the results the of executing them.

Property Inventory

Method Inventory

Properties

property Data as %String [ MultiDimensional ];
Used to store the data returned from the resultset by column name. This can be accessed directly for more performance than the Get() and GetDataByName() as it avoids a method call. For example code that said:
  While result.Next() {
  	Write result.Get("Name"),result.Get("Salary"),!
  }
  
  ; Becomes this faster code
  
  While result.Next() {
  	Write $get(result.Data("Name")),$get(result.Data("Salary")),!
  }
  
Note that as this 'Data' property is multidimensional if there is no such column name as 'Salary' you will get an UNDEFINED error without the $get around it. If there are two columns with the same name in the result set then the second one will be the one referenced by the 'Data' property. If you need to refer to both of them use the GetData() and give the position of the column you want.
Property methods: DataDisplayToLogical(), DataGet(), DataIsValid(), DataLogicalToDisplay(), DataLogicalToOdbc(), DataNormalize(), DataSet()
property RuntimeMode as %String;
Use this method to set the SQL runtime mode for the query to be executed. Setting the runtime mode for this ResultSet does not permanently change the $zu(115,5) value. Possible values mode are:
  • 0 for LOGICAL mode.
  • 1 for ODBC mode.
  • 2 for DISPLAY mode.
  • "" to use the process wide $zu(115,5) value.
Property methods: RuntimeModeDisplayToLogical(), RuntimeModeGet(), RuntimeModeIsValid(), RuntimeModeLogicalToDisplay(), RuntimeModeLogicalToOdbc(), RuntimeModeNormalize(), RuntimeModeSet()

Methods

method %Execute(args...) as %Library.Status
alias for new result set interface
method %Get(name As %String) as %String
Inherited description: Returns the value of the column with the name name in the current row of the result set.

If name is not a valid column name, this method returns an empty string.

method %GetData(n As %Integer) as %String
Inherited description: Returns the value of column colnbr in the current row of the result set.
method %Next(ByRef sc As %Status) as %Integer
Inherited description: Advance the result set cursor to the next row. Returns 0 if the cursor is at the end of the result set.
method Close() as %Status
Closes the current result set cursor.
abstract method ContainsId() as %Integer
If the current query contains an object Id (based on the CONTAINSID parameter being set), return the column position of the object Id. Otherwise return 0.
method Execute(args...) as %Status
Executes the current query.

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

abstract method Get(name As %String) as %String
Returns the value of the column with the name name in the current row of the result set.

If name is not a valid column name, this method returns an empty string. Look at updating the code to use the Data multidimensional property to access the fields faster than using this method call.

abstract method GetColumnCount() as %Integer
Returns the number of columns in the result set.
abstract method GetColumnHeader(n As %Integer) as %String
Returns the column header for column n in the result set.
abstract method GetColumnName(n As %Integer) as %String
Returns the name of column n in the result set.
abstract method GetData(n As %Integer) as %String
Returns the value of column n in the current row of the result set.
abstract method GetDataByName(name As %String) as %String
Returns the value of the column with the name name in the current row of the result set.

If name is not a valid column name, this method returns an empty string.

Note: this method has been superceded by the equivalent Get() method.

abstract method GetExtent() as %String
The name of the extent that this query will return Id values from (based on the EXTENT parameter being set). Only returns a value if the query contains Id values.
abstract method GetObject() as %RegisteredObject
If this query returns the object Id then return the oref you get from opening an object with this id.
abstract method GetParamCount() as %Integer
Returns the number of input parameters for the current query.
abstract method GetParamName(n As %Integer) as %String
Returns the name of input parameter n for the current query.
Advance the result set cursor to the next row. Returns 0 if the cursor is at the end of the result set.
method Prepare(args...) as %Status
Use this method with dynamic queries to provide the query to be executed. In the case of the %DynamicQuery:SQL query, p1 is a string containing an SQL query. The query may contain parameters represented by ? characters within the query. The values of any parameters are supplied via the Execute() method. For example:
  Set result=##class(%ResultSet).%New("%DynamicQuery:SQL")
  
  Do result.Prepare("SELECT Name,City FROM Person WHERE Name %STARTSWITH ? AND City = ?")
  
  Do result.Execute("A","Boston")
  While result.Next() {
  Write result.Data("Name"),result.Data("City"),!
  }
  
abstract method QueryIsValid() as %Integer
Returns true (1) if the ClassName and QueryName properties of this %ResultSet object refer to a valid class query. Otherwise it returns false (0).
classmethod RunQuery(ClassName As %String, QueryName As %String, args...)
This is a diagnostic function; it runs the specified query and prints the output to the console.

Inherited Members

Inherited Properties

Inherited Methods

Subclasses

FeedbackOpens in a new tab