Implementing custom validation checks using Database Consistency Checks feature
Chaitanya Golla
17,225
Hi,
In this post, we will see how can we implement custom validation checks when we run database consistency checks feature.
- Created new tables by name SampleTable and SampleTrans and loaded some data into it.
- Developed a class by name CGConsistencyCheck and included a validation where if due date of record in table SampleTrans is latest when compared to due date on its corresponding record of table SampleTable then warning will be shown stating the same.
- Method run of class CGConsistencyCheck
public void run()
{
SampleTable sampleTable;
SampleTrans sampleTrans;
while select optimisticlock DueDate, Id from sampleTable
join DueDate, RecId, RecVersion, RefId, TransID from sampleTrans
where sampleTrans.RefId == sampleTable.Id
{
if ((sampleTrans.DueDate > sampleTable.DueDate) && (this.checkFix() == CheckFix::Check))
{
checkFailed(strfmt("Due date on Transaction %1 exceeds due date when
compared to due date on its respective header %2", sampleTrans.TransID, sampleTable.Id));
this.updateNotCorrected();
}
}
}
- on executing Consistency check by selecting the node Custom, we get the messages for the SampleTrans records where this validation violation happened.
Output: Info message and Message details
Regards,
Chaitanya
*This post is locked for comments