setMergeEnabled

void sqlDataManager.setMergeEnabled ( boolean merge )

This feature is only available for Professional and Enterprise editions of screen-scraper.

Description

Set merge status for a table. When conflicts exists in data, a merge of true will take the newer values and save them over previous null values.

When merging or updating values in a table, that table must have a Primary Key. When the Primary Key is set to autoincrement, if the value of that key was not set with the addData method the DataManager will create a new row rather than update or merge with an existing row. One solution is to use an SqlDuplicateFilter to set fields that would identify an entry as a duplicate and automatically insert the value of the autoincrement key when data is committed.

By default if the data that you are inserting has the same primary key as data already in the database it will ignore the insert. This behavior can be modified for a specific table by the dm.setUpdateEnabled and dm.setMergeEnabled methods of the DataManager. This allows for four different settings to insert data:

Update Merge Resulting Action
false false Ignore row on duplicate
true false Update only values whose corresponding columns are currently NOT NULL in the database
false true Update only values whose corresponding columns are currently NULL in the database
true true Update all values to new data

Parameters

  • table Name of the database table, as a string.
  • merge Whether to turn on global merge or not, as a boolean.

Return Values

Returns void.

Change Log

Version Description
5.0 Available for professional and enterprise editions.

Examples

Set Database Table Merge

 // Get datamanager
 dm = session.getv( "DATAMANAGER" );

 // Set Merge
 dm.setMergeEnabled( "person", true );

See Also

  • setGlobalMergeEnabled() [SqlDataManager] - Sets whether null values in the database should be overwritten by committed values
  • setGlobalUpdateEnabled() [SqlDataManager] - Sets whether values in the database should be overwritten by committed values, even when the committed value is null
  • setUpdateEnabled() [SqlDataManager] - Sets whether values in a specific table of the database should be overwritten by committed values, even when the committed value is null