Syntax 1 For generating an EAServer result set or an ADO Recordset
Description
Generates a result set from data in a DataStore or DataWindow
control.
In PowerBuilder, when the result set is generated in a component
on a transaction server, the format of the result set is determined
by the server—TabularResults in EAServer and
ADO Recordset on MTS.
Controls
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataStore object |
Syntax
[PowerBuilder]
1 |
integer <span>dsobject</span>.<span>GenerateResultSet</span> (REF ResultSet <span>rsdest</span> { ,dwBuffer <span>dwbuffer</span> } ) |
Argument |
Description |
---|---|
dsobject |
The name of the DataStore object that |
rsdest |
The ResultSet object into which the data |
dwbuffer (optional) |
A value of the dwBuffer enumerated datatype For a list of valid values, see DWBuffer. |
Return Values
Returns 1 if it succeeds and –1 if it fails. If any
argument is null, it returns null.
Usage
How to use it
Result sets are intended for exchanging data between a DataStore
and some data-aware application that does not use DataWindow technology.
With result sets, the receiving end does not support updating of
the data.
The GenerateResultSet method is typically
used in a PowerBuilder custom class user object that has been packaged
as a component on EAServer or on
an MTS server. A function in the user object generates a result
set from information that has been retrieved into a DataStore. The
function then returns the result set or passes it to another method.
For example, a function for PowerBuilder custom class user
object running in a transaction server can retrieve data into a
DataStore object, create a result set object, and return the result
set. A client application calls the function to get the data. The
client application must be able to handle result sets, but it does
not need to have support for DataWindow technology.
Likewise, a client application can generate a result set from
a DataStore and pass the result set to the server.
The CreateFrom method can convert a result
set back to a DataStore.
Result set format
The result set is returned to a client in a format that is standard
for the server. In user objects deployed to EAServer, user-defined functions
that return a PowerBuilder ResultSet object are represented in the
IDL definition of the component as methods that return a result
set of type TabularResults::ResultSet. Multiple result sets returned
in a ResultSets object are represented in the IDL as TabularResults::ResultSets datatypes.
In MTS, returning a result set created by GenerateResultSet causes
an ADO Recordset to be marshaled to the client.
The GenerateResultSet method can also be
called in a client application. Since the format of the result set
depends on the server on which it is used, the format is fixed when
that result set is passed to a server. For EAServer, the
format is TabularResults::ResultSet; for MTS, the format is an ADO Recordset.
The generated ResultSet object maintains a reference to the
DataStore from which it was generated, so changes made to the DataStore
object after the result set is generated will be reflected in the
generated ResultSet object. If you destroy the DataStore object
before returning the result set, the result set becomes invalid.
You can rely on garbage collection to destroy the DataStore object
or destroy it explicitly in the component’s deactivate
event.
Other data exchange techniques
To exchange data between a DataWindow on a client and a DataStore
on EAServer, use the data–synchronizing
methods GetFullState and SetFullState.
With these methods, both controls remain updatable. If updating
is not a concern, you still might choose result sets instead of
synchronizing methods because result sets transfer less data.
Examples
In this example, a DataStore object is created and
data is retrieved into it, and then the GenerateResultSet method
is used to create a result set that can be returned to a client.
1 |
datastore ds_datastore |
1 |
resultset lrs_resultset |
1 |
integer li_rc |
1 |
1 |
ds_datastore = CREATE DataStore |
1 |
ds_datastore.SetTransObject (SQLCA) |
1 |
IF ds_datastore.Retrieve() = -1 THEN |
1 |
... // report error and return |
1 |
END IF |
1 |
1 |
li_rc = ds_datastore.<span>GenerateResultSet</span>(lrs_resultset) |
1 |
IF li_rc <> 1 THEN |
1 |
... // report error and return |
1 |
END IF |
1 |
return lrs_resultset |
See Also
-
SetRecordSet in PowerScript
Reference