Try OpenEdge Now
skip to main content
ProDataSets
Introducing the OpenEdge DataSet : Data-Source object : Defining a static Data-Source : Attaching Data-Sources
 
Attaching Data-Sources
After you have defined a ProDataSet and its Data-Sources, you use the ATTACH-DATA-SOURCE method to associate them. This method, which is described in more detail later in this chapter, lets you specify which fields from the Data-Source go into the ProDataSet, and whether any are renamed in the process. You will learn how to use this method a little later. In the meantime, there are a few rules about how you specify the key fields for a Data-Source.
All the fields in the KEYS phrase must be represented in the ProDataSet buffer that the Data-Source is attached to. That is, they must not be excluded from the table in an EXCEPT list as part of the ATTACH-DATA-SOURCE method that associated the buffer and the Data-Source. The fields might be renamed in the ProDataSet buffer, however, and mapped in the ATTACH-DATA-SOURCE method. Instead of a field list, the KEYS phrase can specify (also within parentheses) the single keyword ROWID, in which case the table ROWID is used as the key for retrieval and updating. In this case, there must be a field in the ProDataSet buffer that is mapped to the table ROWID at the time of the ATTACH.
If you do not specify the KEYS phrase, then the AVM uses one or more primary keys of the database tables to determine the key fields. Therefore, if the primary key is in fact the appropriate key to use to do a unique FIND on a record, then you do not need to specify it in the definition. If the KEYS phrase is not specified and the database tables do not have a unique primary key, then the AVM has no way to locate a record for update or delete or to eliminate duplicate records. This means that if records in the ProDataSet are deleted or updated, the developer must provide an event procedure for that event that handles the operation—there can be no default support provided by the AVM.
Because the KEYS list is associated with a specific buffer, you must include the source-buffer-phrase in the definition if you need to specify the KEYS. If you also specify a QUERY name, then the buffer list itself is really redundant, except to identify which keys go with which buffer, since the query definition also specified them. In this case the AVM simply verifies that the list of buffers is the same.