Previous Topic Next topic Print topic


MERGE

Merges new data into a target DataSet or DataTable.

Syntax, Format 1:

>>--EXEC ADO--.-------------------.-MERGE DATASET FROM ------->
              +-USING dataset_name+


 >---:src_dataset_hv --.--------------------.----------------->
                       +--PRESERVE CHANGES--+


 >---.--------------------------------------.-END-EXEC--------><
     |                                      |
     +-ON SCHEMA DIFFERENCE--+-ADD         -+
                             +-ADD WITH KEY-+
                             +-ERROR       -+
                             +-IGNORE      -+

Syntax, Format 2:

>>--EXEC ADO--.-------------------.-MERGE DATASET ------------>
              +-USING dataset_name+


 >---src_dataset_name -----.--------------------.------------->
                           +--PRESERVE CHANGES--+


 >---.--------------------------------------.-END-EXEC--------><
     |                                      |
     +-ON SCHEMA DIFFERENCE--+-ADD         -+
                             +-ADD WITH KEY-+
                             +-ERROR       -+
                             +-IGNORE      -+

Syntax, Format 3:

>>--EXEC ADO--.-------------------.-MERGE DATATABLE----------->
              +-USING dataset_name+


 >---dest_datatable FROM DATASET src_dataset_name------------->


 >-------------.------------------------------------.--------->
               +-FOR-.-ADDED-------------.-DATAROWS-+
                     +-CURRENT-----------+
                     +-DELETED-----------+
                     +-MODIFIED CURRENT--+
                     +-MODIFIED ORIGINAL-+
                     +-ORIGINAL----------+
                     +-UNCHANGED---------+           


 >--.-------------------------.---.--------------------.------>
    +-WHERE search conditions-+   +--PRESERVE CHANGES--+


 >---.--------------------------------------.-END-EXEC--------><
     |                                      |
     +-ON SCHEMA DIFFERENCE--+-ADD         -+
                             +-ADD WITH KEY-+
                             +-ERROR       -+
                             +-IGNORE      -+

Syntax, Format 4:

>>--EXEC ADO---MERGE DATATABLE-------------------------------->

 >---dest_datatable FROM DATATABLE src_datatable_name--------->

 >---.------------------------------------.------------------->
     +-FOR-.-ADDED-------------.-DATAROWS-+
           +-CURRENT-----------+
           +-DELETED-----------+
           +-MODIFIED CURRENT--+
           +-MODIFIED ORIGINAL-+
           +-ORIGINAL----------+
           +-UNCHANGED---------+           


 >---.-------------------------.---.--------------------.---->
     +-WHERE search conditions-+   +--PRESERVE CHANGES--+


 >---.--------------------------------------.-END-EXEC---><
     |                                      |
     +-ON SCHEMA DIFFERENCE--+-ADD         -+
                             +-ADD WITH KEY-+
                             +-ERROR       -+
                             +-IGNORE      -+

Parameters:

dataset_name The target DataSet to be used. If you do not specify dataset_name, the current DataSet is used.
src_dataset_hv The host variable that contains the source DataSet for the merge.
src_dataset_name The source DataSet name that specifies which DataRows of a DataTable to use as the source for the merge.
dest_datatable The destination into which DataTable data is to be merged.
src_datatable The source that the DataTable data is to be copied from.
search_conditions Any valid expression that can follow the standard SQL WHERE clause.
PRESERVE CHANGES Prevents incoming values from the source overwriting the current values in the target (only Original).
ON SCHEMA DIFFERENCE Specifies what happens if the DataSet or DataTable schemas of the source and target are different.

Comments:

The source of the new data is either a complete DataSet, a DataTable from another DataSet, or a set of DataRows from a DataTable in another DataSet.

In accordance with the .NET API standards, there is an option to preserve changes in the target DataSet or DataTable.

You can also specify what actions are taken if a schema difference is encountered.

Examples:

     EXEC ADO
        MERGE DATASET FROM :changesDSobj
     END-EXEC

     EXEC ADO 
        MERGE DATATABLE TABLE2 FROM DATATABLE TABLE1 FOR ADDED ROWS  
     END-EXEC
Previous Topic Next topic Print topic