Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[tree_tst-catalog_createItem]
- @parameters DictionaryParameter READONLY,
- @parentID nvarchar(128),
- @name nvarchar(128),
- @itemID nvarchar(128),
- @username nvarchar(32)
- AS
- BEGIN
- declare @catParentID int
- set @catParentID = try_cast(@parentID as int)
- if(@catParentID=0) set @catParentID=null
- declare @categoryID int
- insert into tst_categories(name, parentID, ord)
- values (@name, @catParentID, isnull((select max(ord) + 10 from tst_categories where parentID = @catParentID),10))
- set @categoryID = scope_identity()
- declare @l int = 1, @curParentID int
- set @curParentID = @catParentID
- while isnull(@curParentID,0)<>0
- begin
- set @l = @l + 1
- select @curParentID = parentID from tst_categories where id = @curParentID
- end
- update tst_categories set level = @l where id = @categoryID
- declare @code nvarchar(max), @url nvarchar(max)
- set @code = dbo.tst_getCategoryCode(@categoryID)
- update tst_categories set code = @code where id = @categoryID
- set @url = dbo.tst_getCategoryURL(@categoryID)
- update tst_categories set url = @url where id = @categoryID
- -- SELECT 1
- Select 1 Result, '' Msg, @categoryID [NewID]
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement