The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.
CREATE PROCEDURE [dbo].[INSERT_NESTED_SET_WEBPAGE] @varTitle varchar(256), @parent int AS -- get the parent's rgt value DECLARE @parentRight int; SELECT @parentRight = rgt FROM my_data WHERE ID = @parent -- make room for the new child (at the end of the nested set) UPDATE my_data SET lft = lft + 2 WHERE lft >= @parentRight UPDATE my_data SET rgt = rgt + 2 WHERE rgt >= @parentRight -- insert the new child (at the end of the nested set) INSERT INTO my_date (title, lft, rgt) VALUES ( @varTitle, @parentRight, @parentRight + 1) GO
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.