zoukankan      html  css  js  c++  java
  • 简单使用游标更改数据

    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

  • 相关阅读:
    [NOI2014]动物园
    2018.7.15模拟赛
    2018.7.13模拟赛
    [CodeForces]920F SUM and REPLACE
    [BZOJ3211]花神游历各国
    [GSS5] Can you answer these queries V
    [SPOJ1716] GSS3
    [HNOI2012]排队
    2018.7.10模拟赛
    7.3模拟赛
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3305484.html
Copyright © 2011-2022 走看看