Try OpenEdge Now
skip to main content
ProDataSets
Introducing the OpenEdge DataSet : Data-Source object : Defining a static Data-Source : Example
 
Example
In the example for ProDataSet dsOrder, these are the Data-Source definitions, along with their queries:
DEFINE QUERY qOrder FOR Order, Customer, SalesRep.
DEFINE QUERY qItem FOR ITEM.

DEFINE DATA-SOURCE srcOrder FOR QUERY qOrder
  Order KEYS (OrderNum), Customer KEYS (CustNum), SalesRep KEYS (SalesRep).
DEFINE DATA-SOURCE srcOline FOR OrderLine.
DEFINE DATA-SOURCE srcItem FOR QUERY qItem ITEM KEYS (ItemNum).
You need a definition for query qOrder for two reasons. First, it is the top-level query, so unless you want all Orders and all their OrderLines and Items in the ProDataSet at the same time, which is unlikely (and which would be very expensive to load and pass between sessions), you must open that query with specific selection criteria for a single Order or a group of related orders. The second reason it is needed is to join the Customer and SalesRep tables to the Order to pick up the Customer Name and SalesRep Name fields. You cannot do this join without the query because the AVM will not be able to join the tables for you automatically.
There is also a query qItem for the Item table so that under some circumstances you can specify that you want all Items loaded into the ProDataSet.
The Data-Source srcOrder shows you how to define the keys for each table in query qOrder. In this case, each of these is a unique primary key for the table, so the buffer list and the KEYS phrases are not strictly necessary. However, they provide you with explicit confirmation within your procedure of which keys are used to identify records.
Likewise, the phrase ITEM KEYS (ItemNum) is not strictly necessary in the Data-Source srcItem.