TV 3.7.0
Before a cdc watcher can be added, a cdc group has to exist first. Such a group can be created by following the first chapter of the HowTo Guide:
After having created a cdc group a watcher can be added, which manages how often it has to look for new data for this group in the SQL-database. This can either happen scheduled or by being triggered. The watcher can be created by using the script API_DBIADM.ADD_CDCG_WATCH. If a trigger should be used the schema, table and watch_id have to be set accordingly. If necessary casting can be done as well such as casting a datetime into a date. If the watcher should look for new data based on a schedule, schema and table should be set to 'null', while the watch_id is specified using the source dialect, in this case sql statements.
Below an example for a scheduled watcher can be seen.
EXECUTE SCRIPT API_DBIADM.ADD_CDCG_WATCH(
'tst_cdc_grp' -- p_cdc_group
,null -- p_src_schema
,null -- p_src_table
,'to_date(add_hours(systimestamp, -3))' -- p_src_watch_id_expr
);
This command will add an entry in the table DBIADM.DBI_CDCG_WATCH.
cdc_group | src_schema | src_table | src_watch_id_expr |
---|---|---|---|
tst_cdc_grp | (null) | (null) | to_date(add_hours(systimestamp, -3)) |
To modify the parameters of a cdc watcher one has to provide the name of the cdc group that should be modified to the script API_DBIADM.MODIFY_CDCG_WATCH. To retain the value of any of the parameters a null value has to be provided, otherwise the value will be overwritten.
In the example below the specification of the watch id is changed.
EXECUTE SCRIPT API_DBIADM.MODIFY_CDCG_WATCH(
'tst_cdc_grp' -- p_cdc_group
,null -- p_src_schema
,null -- p_src_table
,'to_date(add_hours(systimestamp, -6))' -- p_src_watch_id_expr
);
The change, after having issued the command above, can be seen in the entry for the cdc group 'tst_cdc_grp' in the table DBIADM.DBI_CDCG_WATCH, as is shown below.
cdc_group | src_schema | src_table | src_watch_id_expr |
---|---|---|---|
tst_cdc_grp | (null) | (null) | to_date(add_hours(systimestamp, -6)) |
If a cdc watcher should be removed, one only has to provide the name of the cdc group to the script API_DBIADM.REMOVE_CDCG_WATCH as can be seen in the example below.
EXECUTE SCRIPT API_DBIADM.REMOVE_CDCG_WATCH(
'tst_cdc_grp' -- p_cdc_group
);
After the command above has been issued, the entry for the cdc watcher for the cdc group 'tst_cdc_grp' is deleted from the table DBIADM.DBI_CDCG_WATCH.