日期:2014-05-18 浏览次数:20642 次
create trigger mytri on goods after insert,update as declare @g_id char(20); declare @service_id char(20); declare @Goods_id char(20); declare @B bit =1; declare mycur cursor for select Goods_id from goods; begin --insert into supply values(@g_id,@service_id,NULL); select @g_id=Goods_id from inserted; open mycur; fetch next into @Goods_id; while @@fetch_status=0 begin if @g_id NOT LIKE @Goods_id set @B=0; fetch next into @Goods_id; -- insert into goods values(@g_id,@service_id,NULL,NULL,NULL,NULL); end close mycur; if @B=0 insert into goods values(@g_id,@service_id,NULL,NULL,NULL,NULL); end
create procedure mypro as begin insert into supply values('13','2',NULL); end commit