Using SQL Adapters with Ensemble
Using Result Sets
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

The EnsLib.SQL.GatewayResultSet class represents a special-purpose result set for use in Ensemble. An initialized instance of this class has a live data connection to a data source. The class provides methods to examine the contents of the result set as well as a method to return a static snapshot.

This chapter describes how to use the EnsLib.SQL.GatewayResultSet class. It discusses the following:
Note that you can also get a snapshot that contains rows from the result set; see Using Snapshots.”
Creating and Initializing a Result Set
To create and initialize an Ensemble SQL result set:
  1. Within an SQL adapter (either EnsLib.SQL.InboundAdapter or EnsLib.SQL.OutboundAdapter), connect to a DSN.
  2. Use the ExecuteQuery() or the ExecuteQueryParmArray() method of the adapter. You will receive, by reference, an instance of EnsLib.SQL.GatewayResultSet.
Note:
If you just use the %New() class method, you can create a result set, but it will not be initialized and cannot contain any data. To initialize the result set, use the procedure described here.
Getting Basic Information about the Result Set
The following properties of EnsLib.SQL.GatewayResultSet provide basic information about a result set:
Navigating the Result Set
A result set consists of rows of data. You can use the following methods to navigate through the rows:
Next()
method Next(ByRef pSC As %Status) returns %Integer 
Advances the cursor to the next row and caches the row data. Returns 0 if the cursor is at the end of the result set.
SkipNext()
method SkipNext(ByRef pSC As %Status) returns %Integer 
Advances the cursor to the next row. Returns 0 if the cursor is at the end of the result set.
Examining the Current Row of the Result Set
Use the following methods to examine the current row of the result set:
Get()
method Get(pName As %String) returns %String
Returns the value of the column that has the name pName, in the current row.
GetData()
method GetData(pColumn As %Integer) returns %String 
Returns the value of the column whose position is specified by pColumn in the current row.
GetColumnName()
method GetColumnName(pColumn As %Integer = 0)
Returns the name of the column whose position is specified by pColumn.
Note:
If the source data contains any unnamed columns, the result set automatically provides names for these columns in the following form: xCol_n