Add XML data to a populated temp-table
- Last Updated: June 7, 2019
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
If you need to merge data in an ABL temp-table with
XML data, you can control the way in which the AVM handles duplicate
unique key conflicts with the read-mode parameter.
In this example, a new temp-table is set up with definition from
the Customer table and two new records. This set-up
code is stored in an include file. Note that the first record uses
a customer number that conflicts with one in the XML document. The
second record has no conflict with the XML document, as shown:
|
The following is an abbreviated copy of the ttCustomer.xml file:
|
To illustrate the different results obtained with each read-mode option,
there is a unique index defined for the CustNum field.
There is a record in both the include file and the XML file that
uses the same CustNum value (1). This is known
as a duplicate unique key conflict. The different read modes
respond to such a conflict in different ways.
The code sample below performs the same READ-XML( ) method
call you saw in the last example. Replace the highlighted variable
value in the code with each of the following four read mode tokens
and compare the results:
-
EMPTY -
APPEND -
MERGE -
REPLACE
|
Compare your results to those shown and explained in the following table.
| Read mode | List result | Explanation |
|---|---|---|
EMPTY
|
![]() |
The method empties the existing data from the temp-table. It then reads the XML document and adds records to the temp-table. Since the temp-table is empty, there is no duplicate key conflict. The result is a temp-table with records exclusively from the XML document. |
APPEND
|
![]() |
The method reads the XML document and adds
records to the temp-table. Due to the duplicate key conflict between
the record in the temp-table and the record in the XML with a CustNum of 1,
the method stops loading records and stops. Records added before
a conflict is detected are retained. The AVM displays the error
message shown. |
MERGE
|
![]() |
The method reads the XML document and adds
records to the temp-table. Due to the duplicate key conflict between
the record in the temp-table and the record in the XML with a CustNum of 1,
the record from the XML is ignored. The result is all the existing
records from the temp-table, plus all of the records from the XML except for
the record with a CustNum of 1. |
REPLACE
|
![]() |
The method reads the XML document and adds
records to the temp-table. Due to the duplicate key conflict between
the record in the temp-table and the record in the XML with a CustNum of 1,
the record from the XML replaces the record in the temp-table. The
result is all the existing records from the temp-table except for
the record with a CustNum of 1, plus all of the
records from the XML. |



