Working with a DataStore
To use a DataStore, you first need to create an instance of
the DataStore object in a script and assign the DataWindow object
to the DataStore. Then, if the DataStore is intended to retrieve
data, you need to set the transaction object for the DataStore.
Once these setup steps have been performed, you can retrieve data
into the DataStore, share data with another DataStore or DataWindow control,
or perform other processing.
Examples
PowerBuilder The following script uses a DataStore to retrieve data from
the database. First it instantiates the DataStore object and assigns
a DataWindow object to the DataStore. Then it sets the transaction
object and retrieves data into the DataStore:
|
1 |
datastore lds_datastore |
|
1 |
lds_datastore = CREATE datastore |
|
1 |
lds_datastore.DataObject = "d_cust_list" |
|
1 |
lds_datastore.SetTransObject (SQLCA) |
|
1 |
lds_datastore.Retrieve() |
|
1 |
/* Perform some processing on the data... */ |
PowerJ You can write the code that instantiates a DataStore or you
can add a nonvisual DataStore to a form in the form design window.
The DataStore class is available on the Database page of the Component
palette. If you add the DataStore in the form design window, PowerJ
generates the code for instantiating the object.
Setting the transaction object is necessary only if the DataStore
is intended to retrieve data and you chose a connection method that
requires you to code it.
This code instantiates a DataStore object. Depending on your
design choices, you may need to call only the retrieve method:
|
1 |
powersoft.datawindow.DataStore ds_1; |
|
1 |
ds_1 = new powersoft.datawindow.DataStore( ); |
|
1 |
ds_1.setSourceFileName("dwlibs/mydws.pdb"); |
|
1 |
ds_1.setDataWindowObject("d_cust_list"); |
|
1 |
ds_1.setTransObject(trans_1); |
|
1 |
ds_1.retrieve( ); |