简单实用游标更改数据

简单实用游标更改数据

 

alter proc updatestudent
@id int,
@id2 int
as
declare @schoolid int
declare @classid int
declare @studentid int
declare @idnumber int
declare @idaaa int
begin
declare feeinsertstudent cursor for 
select stuid,schid,clasid from t_school where id=@id
open feeinsertstudent 
fetch next from feeinsertstudent into @schoolid,@classid,@studentid
while @@fetch_status=0
begin
set @idnumber=(select count(*) from t_leaveschool where studentid=@studentid and schoolid=@schoolid and classid=@classid)
set @idaaa=(select count(*) from t_leaveschool where id=@id2)
if(@idnumber!=0)
if(@idaaa!=0)
begin
update t_leaveschool set studentid=@studentid,classid=@classid,schoolid=@studentid where id=@id2
end
fetch  next from feeinsertstudent into @schoolid,@classid,@studentid
end
close feeinsertstudent
deallocate feeinsertstudent


end

 

 

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐