Skip to content

Commit

Permalink
triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
amymluo committed Dec 9, 2018
1 parent 7169d3c commit 320a3ec
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sql_script/petsitting_create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ delimiter //
create trigger check_pet_put_up_is_owners before insert on request
for each row
begin
if (new.pet_id in (select pet.pet_id
if (new.pet_id not in (select pet.pet_id
from pet
join user on (pet.owner_id = user.user_id)
where user.user_id = new.owner_id)) then
signal sqlstate '45000'
set message_text = ' Cannot enter a rating about someone who is not a sitter.';
set message_text = 'Cannot put up a pet that is not your own.';
end if;
end
//
Expand All @@ -175,6 +175,4 @@ create function duration(start date, end date) returns integer
begin
return end - start;
end //
delimiter ;

select duration(date(now()), date_add(date(now()), interval 2 day));
delimiter ;

0 comments on commit 320a3ec

Please sign in to comment.