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


class %Library.RemoteResultSet extends %Library.AbstractResultSet

The %RemoteResultSet class provides a way to use class queries from a different namespace from within a Caché ObjectScript application. It is similar in operation to the ResultSet objects provides with the ActiveX and Java bindings. It uses C++ binding and therefore the C++ binding library must be installed.

You can use a %RemoteResultSet object as follows:

  ; Display the results of the Person class' ByName query to the console.
  Set rs=##class(%RemoteResultSet).%New("Sample.Person:ByName")
  s rs.UserName="_system"
  s rs.Password="sys"
  s rs.ConnectionString="localhost[1972]:SAMPLES"
  w rs.Prepare()
  w rs.Execute("S")
  While rs.Next() {
  	Write rs.GetDataByName("Name"),!

Note you can bind a %ResultSet object to a query by either a) setting the ClassName and QueryName properties or b) passing a string containing the class name and query name (separated by a :) to the %New method:

  Set result=##class(%ResultSet).%New("Person:ByName")

Dynamic SQL

You can use the %ResultSet class to execute dynamic SQL queries using the system-provided %DynamicQuery:SQL query. In this case, use the Prepare() method to supply the text of the query. For example:
  Set result=##class(%ResultSet).%New("%DynamicQuery:SQL")
  Do result.Prepare("SELECT ID, Name, Salary FROM Employee WHERE Salary > ?")
  Do result.Execute(10000)
  While result.Next() {
  	Write result.Data("Name"),result.Data("Salary"),!
Dynamic SQL queries are cached in the same query cache as used by Caché ODBC and JDBC. This means that repeated calls to the same dynamic SQL query do not incur any additional query preparation and optimization overhead. You can view and manage this cache using the Caché SQL Manager.

Property Inventory (Including Private)

Method Inventory (Including Private)

Properties (Including Private)

property AtEnd [ Private , InitialExpression = 0 ];
Property methods: AtEndDisplayToLogical(), AtEndGet(), AtEndIsValid(), AtEndLogicalToDisplay(), AtEndLogicalToOdbc(), AtEndNormalize(), AtEndSet()
property ClassName as %CacheString;
The name of the class containing the query to run.
Property methods: ClassNameGet(), ClassNameIsValid(), ClassNameSet()
property ColIndex [ Private , MultiDimensional ];
Property methods: ColIndexDisplayToLogical(), ColIndexGet(), ColIndexIsValid(), ColIndexLogicalToDisplay(), ColIndexLogicalToOdbc(), ColIndexNormalize(), ColIndexSet()
property ColInfo [ Private , MultiDimensional ];
Property methods: ColInfoDisplayToLogical(), ColInfoGet(), ColInfoIsValid(), ColInfoLogicalToDisplay(), ColInfoLogicalToOdbc(), ColInfoNormalize(), ColInfoSet()
property ConnectionString as %String;
Property methods: ConnectionStringDisplayToLogical(), ConnectionStringGet(), ConnectionStringIsValid(), ConnectionStringLogicalToDisplay(), ConnectionStringLogicalToOdbc(), ConnectionStringNormalize(), ConnectionStringSet()
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("Sa