Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. DELIMITER //
  2. CREATE TRIGGER Carperperson
  3. BEFORE INSERT ON bookings
  4. FOR EACH ROW
  5. BEGIN
  6. IF NEW.customer_id = bookings.customer_id
  7. and ((new.start_date >= bookings.start_date and new.start_date < bookings.end_date)
  8. or (new.end_date > bookings.start_date and new.end_date < bookings.end_date))
  9. THEN
  10. SIGNAL SQLSTATE '45000' set message_text='You can only book one car per single customer a day!';
  11.  
  12.  
  13. DELIMITER;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement