游标例子

declare cur1 cursor for select Year,Period,DeptID,ProjectID,RegCode,TypeCode,ItemCode,Money from @CurTable
 open cur1
 fetch next from cur1 into @Year,@Period,@DeptID,@ProjectID,@RegCode,@TypeCode,@ItemCode,@Money
 while @@fetch_status=0
  begin
   --if @DelFlag=1 --删除流程
   --if @AppFlag=0 and @DelFlag<>1 --流程结束不同意
   if @AppFlag=2 and @DelFlag<>1 --流程下一步
    begin
     exec Form_pYS_AdjustBudget @DeptID,@ProjectID,@RegCode,@Year,@Period,@TypeCode,@ItemCode,@Money,'LockMoney',1
     exec Form_pYS_AdjustBudget @DeptID,@ProjectID,@RegCode,@Year,@Period,@TypeCode,@ItemCode,@Money,'UsageMoney',0
    end
   if @AppFlag=1 and @DelFlag<>1 --流程结束同意
    begin
     exec Form_pYS_AdjustBudget @DeptID,@ProjectID,@RegCode,@Year,@Period,@TypeCode,@ItemCode,@Money,'AppMoney',1
     exec Form_pYS_AdjustBudget @DeptID,@ProjectID,@RegCode,@Year,@Period,@TypeCode,@ItemCode,@Money,'UsageMoney',0
    end
   fetch next from cur1 into @Year,@Period,@DeptID,@ProjectID,@RegCode,@TypeCode,@ItemCode,@Money
  end
 close cur1
 deallocate cur1

posted on 2012-10-18 20:01  鱼人夜行者  阅读(189)  评论(0编辑  收藏  举报

导航