begin tran dupa
declare @itemGroupClothes uniqueidentifier = '8367486C-DAEE-48CB-9707-E335871CCA1D'
declare @itemGroupLiquids uniqueidentifier = 'D9BCAA72-EBE5-4BF7-8F05-65D9AE02C4B9'
declare @itemID uniqueidentifier = ''
declare @username varchar(50) = 'demo'
declare @discountGroupID uniqueidentifier = @itemGroupClothes
declare @changeMainGroupID uniqueidentifier = @itemGroupClothes
declare @itemGroup varchar(max) = (select itemGroup from wms.item where itemID = @itemID and itemGroup not like cast(@itemGroupClothes as varchar(max))) + ',' + cast(@itemGroupClothes as varchar(max))
declare @checkItemCodeTemplate nvarchar(50)
select itemCode from wms.item where itemID = @itemID
if @itemGroup is not null begin
select
@checkItemCodeTemplate =
(
SELECT TOP 1 dict.dictionaryUrl
from dbo.f_TOOLS_Split(@itemGroup,',') gr
inner join common.dictionary dict on gr.idP = dict.dictionaryKeyGuid
where @changeMainGroupID is null or @changeMainGroupID = gr.idP
)
update [wms].[item]
set
[itemGroup] = CASE
when @checkItemCodeTemplate is not null then @itemGroup else [itemGroup]
end,
[modDate] = getutcdate(),
[modUsername] = @username,
fulltextcat = 0 /*reset indexu*/
where
[itemID] = @itemID
IF @itemGroup is not null and @itemGroup<>''
begin
EXEC wms.itemGroup_InsertUpdate @itemID,@username,@discountGroupID,@changeMainGroupID
end
end
select itemCode from wms.item where itemID = @itemID
rollback tran