We want to add a constraint in a Oracle database to check if the employee’s salary respects the hierarchy.
An employee has an id, a name, a rank and a salary.
We have 3 ranks (rank1, rank2, rank3), rank1 is superior to rank2 and rank2 is superior to rank3.
When adding an employee that has rank2, his salary shouldn’t be superior to a salary of an employee with rank1.
Can you tell us which solution is the best to implement this constraint ?
Thank you very much
I think you’ll end up having to use a trigger, and since you’ll need to refer to data within the same table on which the trigger exists it’ll need to be a table trigger rather than a row trigger. Something like this:
I’ve used similar triggers to check data validity and have found it works well.
Share and enjoy.