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

    SET NOCOUNT ON
    DECLARE @startip bigint
    declare @addr nvarchar(
    50)
    DECLARE @endip bigint
    declare @detailaddr varchar(
    100)
    declare @countnumber 
    int
    declare @cid 
    int
    set @countnumber=0
    DECLARE publish_cursor CURSOR FOR 
    SELECT cast(rtrim(startip) 
    as bigint),cast(rtrim(endip) as bigint),rtrim(addr),rtrim(detailaddr),id FROM t_ip
        OPEN publish_cursor

        FETCH NEXT FROM publish_cursor
        INTO @startip,@endip,@addr,@detailaddr,@cid

            WHILE @@FETCH_STATUS 
    = 0
            BEGIN
            print @cid
                
    --修改记录
                update t_ip 
    set ip1=@startip,ip2=@endip,addr1=@addr,addr2=@detailaddr where id=@cid
                
    --修改结束
                FETCH NEXT FROM publish_cursor into  @startip,@endip,@addr,@detailaddr,@cid
                
            END
        CLOSE publish_cursor
        DEALLOCATE publish_cursor
        
    GO

    用来实现存储过程中对 select数据集的 读取

  • 相关阅读:
    单例模式
    关于static
    在O(1)时间复杂度删除链表节点
    奇偶分割数组
    用栈实现队列
    前序遍历和中序遍历树构造二叉树
    扇贝每日一句_1006
    寻找旋转排序数组中的最小值
    翻转链表
    扇贝每日一句_1002
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1525739.html
Copyright © 2011-2022 走看看