Create TRIGGER tg_bcnum ON [dbo].[mps_comment] AFTER Insert,delete
NOT FOR REPLICATION
AS
IF Update (c_id)
declare @orderN varchar(50)
declare @num varchar;
declare y_curr cursor for select b_id from [dbo].[mps_bookPlan]
open y_curr
fetch next from y_curr into @orderN
while(@@fetch_status=0)
begin
select @num=count(c_id) from mps_comment where c_bid=@orderN
update mps_bookPlan set b_cnum=@num where b_id=@orderN
fetch next from y_curr into @orderN
end
close y_curr
deallocate y_curr
触发器和游标的第一次使用
最新推荐文章于 2024-04-07 21:26:07 发布