Try OpenEdge Now
skip to main content
DataServer for Oracle
Initial Programming Considerations : Record creation : Ensuring record are created in a predictable order
 

Ensuring record are created in a predictable order

Records created within a transaction are not necessarily created in a predictable order. For example, when two records from two tables are created within the same transaction, you might expect that there is a sequential order to the record creation process; the initial record would be created first followed by the second and so forth. However, it is possible that the second record is created before the first record. The unpredictable nature of the record creation process can therefore affect the integrity of your data should the data require a predictable order to the write process on the Oracle data source.
Progress Software Corporation recommends that you use one of the following ABL language elements to force the order in which ABL records are written to the Oracle data source:
*Release statement
*Validate statement
*RECID function
For example, the following code example shows two transactions: master and detail. In the initial sample code pair, it is possible that the detail code could be created before the master code:
CREATE master.
ASSIGN master.name = "transaction".
CREATE detail.
ASSIGN
  detail.name = "transaction"
  detail.id   = 10.
The following sample code pair shows the identical transactions as those previously presented. However, note the addition of the VALIDATE phrase to the master record to ensure that the master record is created before the detail record:
CREATE master.
ASSIGN master.name = "transaction".
VALIDATE master.
CREATE detail.
ASSIGN
  detail.name = "transaction"
  detail.id   = 10.