The Select / Update function on a Mapping screen lets you update selected fields in a target database. This screen is used only for the JDBC data source, as it allows you to synchronize new data with existing data in a target database. As a result of a data transfer, target records are created for the target data source. Using this screen target records can be updated in very specific ways. For each record created you can specify criteria in this screen for merging the new data with data already in the target source. Briefly you first check for the existence of matching target records and then decide on the basis of specific update criteria, whether to insert the new data record or leave the existing record. Merge updates will only occur where the update information provides the appropriate mapping.
Note that when using the Select / Update Criteria screen, select fields do not have to be the same as the update fields. The select fields chosen will determine which rows get retrieved. The update fields are the one used for comparison to determine if the row needs to be updated. In normal insert/update environments this can be left blank.
In the target data source there must be at least one field with the Unique Key property of the field turned on. This is used by the system to decide which rows if any to insert or update. If there is no Unique Key and you are trying to use the SELECT/UPDATE strategy, then when a condition is found that will cause an UPDATE to a row, it will fail because the row cannot be uniquely identified in the generated update statement.
Use the Select / Update icon on the Mapping window when a target entity is selected, to access the Select / Update criteria. At the top of the screen the current entity from the Mapping screen is identified, and you choose whether to perform a select/update on this entity:
Entity: The entity selected when you used the Select / Update button will be shown at the top of the screen. This is the table you are currently synchronizing.
Do select / update: Check this button to enable Select/Update. If it is not checked every new record created by the data transfer will be inserted into the target table.
Insert if no record found? When this is checked, then if no existing record is found in the target database that matches the select criteria, then the new record created by the transfer will be inserted. That is, if no record is found, and this box is checked, then the new record is inserted into the target database. If the box is not checked and no record is found, nothing occurs, i.e. no new record is inserted..
The Select fields area of the screen is used to identify matching records, and Update criteria allows a comparison between new and existing records. On the basis of this information you can make a decision for each field, whether to update it or not.
Select fields:
provides filter information to identify records in the target data source,
i.e. you will enter the fields used to identify an existing record in
the target database. The system will take the data from those fields in
the new record and will attempt to match that data in the target database.
This is used to find out if there is already a matching record in the
target
Add/ Remove Fields: Press Add to see a list of fields of the
current entity in a Select window on screen so that you choose which to
include in the box. Highlight the required
fields and press Select to have them entered in the Select Field list.
Select a field in that box and press Remove to delete this field from
the list.
If a record matching the select fields is found, then the Update criteria information is processed
Update criteria:
allows the user to only update existing data if the new record satisfies
particular criteria. That is, having found that there is a matching record
you can decide, using these criteria, whether to update the old record
or not. For example "last modified date" might be used as a
criterion and you might want an operator to specify that the last modified
date of the existing record must be older than the new record. If
this condition is met then the existing record should merged with the
new and updated. This is a "merge" in the sense that other fields
in the existing record that were not mapped in the data transfer, are
left unchanged. This allows a user under some conditions update a single
field in a target record. The
entire record is not necessarily overwritten.
Press the down arrow opposite the Operator heading to see a list of
operators and select an operator appropriate to the condition you want
to define.
A merge update of the data source will not overwrite fields unless they have been mapped, i.e. unless they meet the update criteria specified in this section of the screen.
Related topics include Mapping, Example JDBC mapping