|
CREATE PROCEDURE [dbo].[MoveNodeUp]
@type_id int
AS
declare @lft int
declare @rgt int
declare @layer int
if exists (select 1 from tree where type_id=@type_id)
begin
SET XACT_ABORT ON
BEGIN TRANSACTION
select @lft=lft,@rgt=rgt,@layer=layer from TreeView where type_id=@type_id
if exists (select * from TreeView where rgt=@lft-1 and layer=@layer)
begin
declare @brother_lft int
declare @brother_rgt int
2 select @brother_lft=lft,@brother_rgt=rgt from TreeView where rgt=@lft-1 and layer=@layer
update tree set lft=lft-(@brother_rgt-@brother_lft+1) where lft>=@lft and rgt<=@rgt
update tree set lft=lft+(@rgt-@lft+1) where lft>=@brother_lft and rgt<=@brother_rgt
update tree set rgt=rgt-(@brother_rgt-@brother_lft+1) where rgt>@brother_rgt and rgt<=@rgt
update tree set rgt=rgt+(@rgt-@lft+1) where lft>=@brother_lft+(@rgt-@lft+1) and rgt<=@brother_rgt
end
COMMIT TRANSACTION
SET XACT_ABORT OFF
end
中的select 1 from tree where type_id=@type_id这里的 1 是什么意思呢?谢謝大家歡迎来到Java学习者论坛,转載請注明地址:http://www.javaxxz.com. |
|