zoukankan      html  css  js  c++  java
  • sql存储过程删除无限极分类


    create procedure pro_delete
    @deleteId int
    as
    declare @nodeid int
    declare @id int
    declare @pid int
    set @nodeid = @deleteId
    set @id = @nodeid
    set @pid = @nodeid
    begin transaction
    while(exists (select * from H where id = @nodeid))
    begin
            if(exists (select * from H where Pid = @id and id != @id) )
            begin
                    set @pid = @id
                    set @id = (select top 1 id from H where pid = @id and id != @id)
            end
            else
            begin
                    print @id
                    delete from H where id = @id
                    set @id = @pid
                    set @pid = (select top 1 pid from H where id = @pid)
            end
    end
    if(@@ERROR<>0)
     ROLLBACK TRANSACTION
    else
     commit transaction

  • 相关阅读:
    冗余链接-684-并查集
    Chrome浏览器进程
    BFC布局规则
    Front-end 前端优化总结
    Flex弹性布局
    Browse兼容性问题
    组合关系与组合模式
    YUI3组件框架之plugin
    javascript数据类型及转换
    矩阵打印
  • 原文地址:https://www.cnblogs.com/caishuowen/p/2032984.html
Copyright © 2011-2022 走看看