setUpdateEnabled
void sqlDataManager.setUpdateEnabled ( boolean update )
This feature is only available for Professional and Enterprise editions of screen-scraper.
Description
Set update status for a given table. When conflicts exists in data, an update of true will take the newer values and save them over previous non-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 The name of the database table, as a string.
- update Whether to turn on global update 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 Update
// Get datamanager
dm = session.getv( "DATAMANAGER" );
// Set Update on person table
dm.setUpdateEnabled( "person", true );
dm = session.getv( "DATAMANAGER" );
// Set Update on person table
dm.setUpdateEnabled( "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
- setMergeEnabled() [SqlDataManager] - Sets whether null values in a specific table of the database should be overwritten by committed values
scraper on 07/16/2010 at 5:23 pm
- Printer-friendly version
- Login or register to post comments