• 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

  • 相关阅读:
    ble_app_hrs心率程序 nrf51822
    2019.05.08 《Linux驱动开发入门与实战》
    函数指针
    typedef
    回调函数
    android2
    android1
    每周总结2
    HTML
    数组(续)
  • 原文地址:https://www.cnblogs.com/caishuowen/p/2032984.html
Copyright © 2020-2023  润新知