zoukankan      html  css  js  c++  java
  • 嵌套游标的使用

    declare cur1 cursor for
        select ... from table_name1 where ...group by / order by ...
         open cur1
        FETCH   NEXT   FROM   cur1  INTO  ...
         while (@@FETCH_STATUS = 0 )
           begin
            ....
               declare cur2 cursor for
                  select ... from table_name2 where ...group by / order by ...
                   set @sql='select ... from table_name2 where ...group by / order by ...'
                   exec @sql
                    open cur2
                      FETCH   NEXT   FROM   cur2  INTO  ...
                       while (@@FETCH_STATUS = 0 )
                          begin
                             ....
                            FETCH   NEXT   FROM   cur2  INTO  ...
                          end
                             ....
                   close cur2
                 DEALLOCATE cur2

            FETCH   NEXT   FROM   cur1  INTO  ...
          end
         close cur1
       deallocate cur1

  • 相关阅读:
    PHP线程安全
    Oracle中MD5+Base64加密实现
    1002. A+B for Polynomials (25)
    1001. A+B Format (20)
    Rails,uva 514
    Database,Uva1592
    Hello World for U
    D3.js 力导向图
    从零开始CSS(一 2016/9/21)
    从零开始HTML(三 2016/9/20)
  • 原文地址:https://www.cnblogs.com/dushu/p/2513343.html
Copyright © 2011-2022 走看看