Complete example of client and server code to update a dataset
- Last Updated: October 18, 2024
- 4 minute read
- OpenEdge
- Version 12.2
- Documentation
The following example demonstrates the client and server code for working with data in a dataset.
Include file for both client and server
The following include file code contains the temp-table, dataset, and data-source definitions. The file is used on both the client and the server.
|
Example code on client
client.p is the procedure code on the client-side. This procedure performs the following steps:
- Define the temp-tables, dataset, and data-sources.
The procedure uses an include file to define the temp-tables, dataset, and data-sources for the application. This same include file is also used on the server.
- Connect to the server.
The procedure connects to the server and runs datasetProcs.p persistently. datasetProcs.p contains two server procedures that the client calls.
- Fill the dataset with data from the server.
The empty, working dataset,
dsOrderOrderLine, is passed as a parameter to thefillOrderOrderLinesDSprocedure, which runs on the server. Upon returning to the client, the dataset is now populated with the data from the data-sources. - Update some data in the dataset.
A
ttOrderrecord is retrieved so that it can be updated.TRACKING-CHANGESis turned on for both the temp-tables (ttOrderandttOrderLine) in the dataset. ThettOrderrecord is updated with a ship date and a newttOrderLinerecord is created. After the updateTRACKING-CHANGESis turned off. - Send the updated data to the server so it can be updated on the
server.
A changes-only dataset is prepared to send to the server. This changes-only dataset is then passed as a parameter to the
updateOrderOrderLineDSprocedure, which runs on the server and makes the updates. - Merge the changes back into the working dataset on the client.
After returning to the client, if there were no errors,
MERGE-CHANGESis called to merge the changes back into the working dataset on the client. The client and server data are now in sync.
|
Example code on server
The server code, datasetProcs.p,
uses the same include file to define the temp-tables, dataset, and data-sources. The
code contains two internal procedures, fillOrderOrderLineDS and updateOrderOrderLineDS. The fillOrderOrderLineDS procedure performs the initial
FILL of the dataset with records from the data-sources. The
updateOrderOrderLineDS procedure updates the
data-sources by calling SAVE-ROW-CHANGES to validate and then
update the affected records.
|