Allow only 3 rows to be added to a table for a specific value

前端 未结 3 1987
悲&欢浪女
悲&欢浪女 2020-12-11 09:58

I have a question in hand where i need to restrict the number of projects assigned to a manager to only 3. The tables are:

Manager:
Manager_employee_id(PK)
M         


        
3条回答
  •  情书的邮戳
    2020-12-11 10:11

    I would do the following:

    1. Create one SP for both operation insert/update.
    2. Check with IF not exists Project_manager_employee_id(FK) count < 3 then only proceed for insert/update. otherwise send Throw error.

提交回复
热议问题