Custom Change Detection¶
There may be situations where automatic detection of changes is unsuitable, perhaps because changes need to be detected in a very indirect way. In order to handle this there is the option to use custom change detection, where the model itself determines what changes have occurred. To use custom change handling, simply use the key word 'customchangehandler' in the data fetch and specify the name of a function that will return the changes, e.g. 'customchangehandler = Get_Activity_Changes;'. The template model will then generate a stub method which should be overridden in the model plsql file.
It is worth noting that it is still possible to use triggers with custom change detection. Simply specify the triggers you wish to be added in the normal way, and changes will be logged in the Scheduling_Change_Log table. The custom change handler function takes as input a last_change_log_id which can then be used to lookup any changes that have occurred since this point for the specified triggers.
The custom change handler method should return a pipelined array of records of the same type as a the data fetch, e.g. a custom change handler for an Activity data fetch should return a pipelined array of Scheduling_SYS.Activity_Rec rows. This will be clear from the default function that is created by the template.
To specify that a row is a deletion, simply set the _is_deleted_ flag on the record to 1. It is only necessary to include the primary key attributes on such records.