This example demonstrates the use of a DataStore to retrieve data in a server component. The server component uo_customers has a function called retrieve_custlist. retrieve_custlist generates an instance of the DataStore ds_datastore and then uses this DataStore to retrieve all of the rows in the Customer table. Once the data has been retrieved, retrieve_custlist passes the data back to the client application.
The retrieve_custlist function has an argument called customers, which is defined as an array based on the structure st_custlist. The structure st_custlist has the same layout as d_custlist, the DataWindow object used to access the database. The return value for retrieve_custlist, which is used to return the number of rows retrieved, is of type Long.
Here is the signature of the retrieve_custlist function:
retrieve_custlist( REF st_custlist customers [] ) returns long
Here is the script for the retrieve_custlist function:
datastore ds_datastore long ll_rowcount ds_datastore = create datastore ds_datastore.dataobject = "d_custlist" ds_datastore.SetTransObject (SQLCA) IF ds_datastore.Retrieve() <> -1 THEN ll_rowcount = ds_datastore.RowCount() END IF customers = ds_datastore.object.data destroy ds_datastore return ll_rowcount
At the conclusion of processing, the function retrieve_custlist destroys the DataStore and returns the number of rows retrieved back to the client.