zoukankan      html  css  js  c++  java
  • SQL 游标 指针

    DECLARE @radioScoreRate decimal
    DECLARE @checkScoreRate decimal
    DECLARE @judgeScoreRate decimal
    DECLARE @radioQty decimal
    DECLARE @checkQty decimal
    DECLARE @judgeQty decimal
    DECLARE @examId uniqueidentifier
    DECLARE My_Cursor CURSOR
    FOR (SELECT examId,radioScoreRate,checkScoreRate,judgeScoreRate,radioQty,checkQty,judgeQty FROM El_ExamInfo)
    OPEN My_Cursor; --打开游标
    FETCH NEXT FROM My_Cursor INTO @examId,@radioScoreRate,@checkScoreRate,@judgeScoreRate,@radioQty,@checkQty,@judgeQty;
    WHILE @@FETCH_STATUS = 0
    BEGIN

    update El_ExamInfo set singleRadioScore=@radioScoreRate/case when @radioQty>0 then @radioQty else 1 end ,singleCheckScore=@checkScoreRate/case when @checkQty>0 then @checkQty else 1 end , singleJudgeScore=@judgeScoreRate/case when @judgeQty>0 then @judgeQty else 1 end where examId=@examId

    FETCH NEXT FROM My_Cursor INTO @examId,@radioScoreRate,@checkScoreRate,@judgeScoreRate,@radioQty,@checkQty,@judgeQty;
    END
    DEALLOCATE My_Cursor;

  • 相关阅读:
    关于MySQL数据库中null的那些事
    Java集合之Collections 剖析
    字符串类
    C++标准库
    << 操作符
    操作符的重载
    类中的重载
    友元
    二阶构造模式
    静态成员函数
  • 原文地址:https://www.cnblogs.com/it1042290135/p/7760283.html
Copyright © 2011-2022 走看看