GenerateResultSet
method (DataWindows)
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 ADO Recordset on
MTS.
Applies to
|
DataWindow type |
Method applies to |
|---|---|
|
PowerBuilder |
DataStore object |
Syntax
PowerBuilder
|
1 |
integer dsobject.GenerateResultSet (REF ResultSet rsdest { ,dwBuffer dwbuffer } ) |
|
Argument |
Description |
|---|---|
|
dsobject |
The name of the DataStore object that contains the |
|
rsdest |
The ResultSet object into which the data in the |
|
dwbuffer (optional) |
A value of the dwBuffer enumerated datatype For a |
Return value
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 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 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 MTS, the format is an ADO Recordset.
Destroying or modifying the DataStore
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.
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
datastore ds_datastore resultset lrs_resultset integer li_rc ds_datastore = CREATE DataStore ds_datastore.SetTransObject (SQLCA) IF ds_datastore.Retrieve() = -1 THEN ... // report error and return END IF li_rc = ds_datastore.GenerateResultSet(lrs_resultset) IF li_rc <> 1 THEN ... // report error and return END IF return lrs_resultset |
See also
SetRecordSet in the section called “SetRecordSet” in PowerScript Reference