主题:急CALL啊!帮一下忙好吗!明天要交设计拉
为buy_insert建立插入触发器
1)、CREATE TRIGGER buy_insert ON buy_ticket
for insert
AS
update ticket
set selled=selled+1,rest=rest-1
where train =(
select top 1 s1.Train
from station s1,station s2,inserted
where s1.sname=inserted.tstart and s2.sname=inserted.tend and s1.train=s2.train and s1.sno<s2.sno)
and rest-booked>0
作用:当用户买票时(即buy_ticket插入一行) 此时触发使ticket表的selled+1,rest-1
即各车次已售出票数和未售出票数
这个是火车的管理系统的触发器的问题!我看不懂!帮我解析一下好吗?谢谢
[em18]
1)、CREATE TRIGGER buy_insert ON buy_ticket
for insert
AS
update ticket
set selled=selled+1,rest=rest-1
where train =(
select top 1 s1.Train
from station s1,station s2,inserted
where s1.sname=inserted.tstart and s2.sname=inserted.tend and s1.train=s2.train and s1.sno<s2.sno)
and rest-booked>0
作用:当用户买票时(即buy_ticket插入一行) 此时触发使ticket表的selled+1,rest-1
即各车次已售出票数和未售出票数
这个是火车的管理系统的触发器的问题!我看不懂!帮我解析一下好吗?谢谢
[em18]