Control the filling of each table
- Last Updated: March 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
You can issue a FILL on a
ProDataSet or a buffer any number of times. For example, you might
do this to load data from multiple Data-Sources into a single ProDataSet,
which you could do by successively attaching different Data-Sources
to the ProDataSet member buffer. Or you could modify the Data-Source
query if you needed multiple successive sets of selection criteria
to be used to populate all the data needed. Whether this could result
in duplicate rows or other problems is determined by setting an
attribute called FILL-MODE.
A ProDataSet
buffer has a FILL-MODE attribute that can be set
to one of several character values:
-
EMPTY— If there is any data in the table it is emptied before the fill begins. -
NO-FILL— This means that the table should not be filled at all on aFILLmethod because it has already been filled on a previous operation, or it will be filled separately. This might typically be used when one or more data tables are filled once with static or relatively static data that does not change when other data changes; for example, a list of codes that remains constant even as the rest of the ProDataSet is being reused and refilled for differentOrdersand their related records. If aNO-FILLdata table is encountered in the course of a fill that is initiated at a higher level, then that table is not touched, and any relations to child buffers are not traversed, so theFILLeffectively stops on that branch of the relation hierarchy. If you issue aFILLdirectly on a buffer markedNO-FILL, no error results, and no data is loaded into that buffer's temp-table, beyond what might already be there. -
APPEND— AFILLon a buffer whoseFILL-MODEisAPPENDadds records in addition to anything that is already there, without doing any record comparisons. If this creates duplicate records that violate a unique index constraint on the temp-table, errors will result and the developer must cope with them. This mode is appropriate when you are implementing some form of batching, when a number of rows are added to a table on oneFILLand then the following set on anotherFILL. However, keep in mind thatMERGEmode is nearly as efficient asAPPENDmode, so generally you should use theAPPENDmode only when you want to be notified with a message about duplicates that occur rather than having them skipped without notification. -
MERGE—MERGEis the defaultFILL-MODE. This mode tells the AVM to check for records that are already in the temp-table, based on the table's unique index, and otherwise add new records to the table. This assures that there are no duplicates. Note thatMERGEmode requires that there is a unique primary index using theKEYSfields on the buffer's temp-table. The AVM simply allows the standard database support code to attempt to add each new record to the temp-table. If this fails because of a duplicate key violation in a unique index for the temp-table, that error is suppressed. The cost to this is minimal. Also, inMERGEmode, if a record with the same key is found, it is not replaced. Thus,MERGEcannot be used to refresh records already in a ProDataSet, but can make it possible to fill a ProDataSet in such a way that the same record might be encountered twice without error or duplication. If you need to refresh records in a ProDataSet table, you can set the table'sFILL-MODEtoEMPTY, or you can delete all records or selected records you need to refresh before doing theFILL. -
REPLACE— IfREPLACEis set, the AVM checks each row being filled to see if it is already in the ProDataSet temp-table, based on the temp-table's unique primary index. If a row with the same key values is already present, its field values are replaced by the field values from the database. If it is not already there, it is created in the temp-table. ThisFILL-MODEcan be useful in situations where a row coming from the database may or may not be a duplicate of a row already in the ProDataSet. If the application cannot know which rows may have different values from the current values, it is not feasible to pre-delete the old row(s) reliably before doing aFILLthat brings in new values. Keep in mind that this option is significantly more expensive than usingAPPENDorMERGEmodes, and therefore you should use it only in situations where it is needed.