Try OpenEdge Now
skip to main content
DataServer for Oracle
Initial Programming Considerations : Record creation : Comparing record creation behavior
 

Comparing record creation behavior

Record creation behavior differs between an OpenEdge database and an Oracle database accessed through the DataServer. The following code fragments provide examples of the different behavior.
If you have a table called customer with a field called custnum defined as an indexed field, and you write the following procedure:
CREATE customer.
ASSIGN
  customer.name    = "SMITH"
  customer.custnum = 10
  customer.address = "1 Main St".
ABL — Does not create the record right away (at the CREATE statement). It writes it to the database at the end of the record scope or when the index information is supplied. In this example, ABL writes the record after the statement:
customer.custnum = 10
OpenEdge DataServer for Oracle — Writes the record to Oracle later than it is written to an OpenEdge database. The DataServer writes the record at the end of the record scope.
Another example of the differences between ABL and the DataServer occurs if you write a procedure similar to the following:
DEFINE BUFFER bfCustomer FOR customer.

CREATE customer.
customer.custnum = 111.

FIND bfCustomer WHERE bfCustomer.custnum = 111.
DISPLAY bfCustomer.
ABL — Displays customer 111.
OpenEdge DataServer for Oracle — Fails to find customer 111 because it has not yet written the record that contains customer 111 to the database.
To get the correct response from the DataServer, use the following program:
DEFINE BUFFER bfCustomer FOR customer.

CREATE customer.
customer.custnum = 111.
VALIDATE customer. /* or RELEASE customer. */

FIND bfCustomer WHERE bfCustomer.custnum = 111.
DISPLAY bfCustomer.
In this example, however, using a VALIDATE statement causes the DataServer to write the record to the database. The VALIDATE statement causes the DataServer to write the record that contains customer 111 to the database before the FIND statement occurs. The RELEASE statement also causes the DataServer to write the record to the database; however the RELEASE statement clears the contents of buffers.
Note: Using the ROWID function might cause a newly created record to be written earlier to an Oracle database than to an OpenEdge database. If you do not assign values to all mandatory fields for a record, the ROWID function will fail.
This difference in behavior might also be apparent when you open a query. Newly created records might not appear in the results set of queries that you opened before you created the records. Reopen the query to access the new records.