database developement - enforce buisness rule with trigger

  • I am developing a database that will be used to track secondments within an organistaion. One of the main business rules is that an employee may be seconded to another department for one for quarter up to a maximum of 2 times per year. i think the best way to do this would be to use a trigger to check whether an employee is has been seconded more than twice. If so it should provide some notification and prevent the registration taking place.

    The general schema contains an employee table, department table, quarter table,secondment table. What would be the best way to implement this trigger? Should I create a table to keep tally of the secondements. Any ideas would be very much appreciated

  • Are you looking to return an error when this occurs?

    I assume you are merely looking for a count for each employee for a year, correct? I would write a proc that checks a particular employee's validity for secondment and returns a value that indicates whether or not this is OK.

    In a trigger, you can then call this proc and raise an error if there is a problem.

  • Yeah, i am just looking for a notification error to in for the user that this employe cannot intern more the twice. I will go with the proc to check if the number of rows per employee is no greater than 2.

    thanks for your help

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply