TRIGGERS


create trigger foxes_warning
on SmallWild
after insert
as
declare @fox int, @swid int
select @swid = inserted.SW_ID from inserted
select @fox = Fox from SmallWild
where SW_ID = @swid
print 'forest id ' + cast(@swid as varchar)+
'has ' + cast(@fox as varchar) + 'foxes'
if @fox >700
	print 'ok'
else
	begin
		print 'not ok'
		raiserror ('not enough population',9,1)
		rollback
	end