How to write a constraint (table level unique, using GIST and or EXCLUDE ) to perform duplication record validation using the following rule:
- Entered from_date and to_date values should not be equal or within the range, and
- Employee_id should not be equal, and
After the validation, an error message should be return saying 'Duplicate Entry'. This is in postgreSQL.
Note: I am new to postgreSQL (worked in MS SQL Server and MySQL).
Thanks in advance.
pendingevents can't be done with an exclusion constraint - only with a filtered unique index. But that in turn doesn't support exclusion constraints. So the combination of all three doesn't really seem possible. What would be possible is to prevent overlapping ranges for an employee_id with the same status (so no overlapping pending, no overlapping "final" etc)