Passing result sets
PowerBuilder provides two system objects to handle getting
result sets from components running in EAServer and
returning result sets from PowerBuilder user objects running as EAServer components. These system
objects, ResultSet and ResultSets, are designed to simplify the
conversion of transaction server result sets to and from DataStore
objects and do not contain any state information. They are not designed
to be used for database updates. You use the CreateFrom and GenerateResultSet functions
on the DataStore object to convert the result sets stored in these
objects to and from DataStore objects.

GenerateResultSet has an alternative syntax
used for returning a Tabular Data Stream result set when using MASP
(Method as Stored Procedure) with EAServer.
For more information, see the DataWindow Reference.
Component methods that return result sets use the TabularResults
module. Single result sets are returned as TabularResults::ResultSet
structures. Multiple result sets are returned as a sequence of ResultSet
structures using the TabularResults::ResultSets datatype.
Accessing result sets in EAServer components
from PowerBuilder clients
When you generate an EAServer proxy
object in PowerBuilder for an EAServer component
method that returns TabularResults::ResultSet, the method on the
proxy object returns a PowerBuilder ResultSet object. Methods that
return multiple result sets return a PowerBuilder ResultSets object.

You can view the properties and methods of EAServer proxy objects on the Proxy
tab in the PowerBuilder Browser.
You can access the result set from a PowerBuilder client by
creating an instance of the component, calling the method, and then
using the result set to populate a DataStore object with the CreateFrom function.
This example creates an instance of the SVUBookstore component
and calls the GetMajors method:
1 |
SVUBookstore lcst_mybookstore<br>resultset lrs_resultset<br>datastore ds_local<br>integer li_rc<br> <br>// myconnect is a Connection object<br>li_rc = myconnect.CreateInstance(lcst_mybookstore)<br>IF li_rc <> 0 THEN<br>   MessageBox("Create Instance", string(li_rc) )<br>   myconnect.DisconnectServer()<br>   RETURN<br>END IF<br> <br>lrs_resultset = lcst_mybookstore.GetMajors()<br>ds_local = CREATE datastore<br>ds_local.CreateFrom(lrs_resultset) |
Returning result sets from EAServer components
To pass or return result sets from a PowerBuilder user object
that will be deployed to EAServer,
set the datatype of a function’s argument or return value to
ResultSet (for a single result set) or ResultSets (for multiple
result sets). When the user object is deployed as an EAServer component, the ResultSet and
ResultSets return values are represented in the IDL interface of
the component as TabularResults::ResultSet and TabularResults::ResultSets datatypes.
In this example, a DataStore object is created and data is
retrieved into it, and then the GenerateResultSet function
is used to create a result set that can be returned to a client:
1 |
datastore ds_datastore<br>resultset lrs_resultset<br>integer li_rc<br> <br>ds_datastore = create datastore<br>ds_datastore.dataobject = "d_empdata"<br>ds_datastore.SetTransObject (SQLCA)<br>IF ds_datastore.Retrieve() = -1 THEN<br>   // report error and return<br>END IF<br>li_rc = ds_datastore.generateresultset(lrs_resultset)<br>IF li_rc <> 1 THEN<br>   // report error and return<br>END IF<br>return lrs_resultset |