if exists (select *
from dbo.sysobjects
where id = object_id(N'[dbo].[p_GetFrameworkCommandUniqueId]')
and objectproperty(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_GetFrameworkCommandUniqueId]
go
/*
Returns unique id for the command with the given id.
*/
create procedure dbo.p_GetFrameworkCommandUniqueId
(
@ApplicationCd UDT_STRING,
@CommandId UDT_LONGSTRING,
@UniqueId UDT_OBJID OUTPUT
)
as
begin
if (@CommandId is null or @CommandId = '')
return;
if (@ApplicationCd is null or @ApplicationCd = '')
return;
select @UniqueId = Unique_Id from Framework_Commands with (TABLOCKX)
where CommandId = @CommandId and ApplicationCd = @ApplicationCd;
if (@UniqueId is null) begin
exec p_GetFrameworkSequenceNextValue @UniqueId output;
insert into Framework_Commands (ApplicationCd, CommandId, Unique_Id)
values (@ApplicationCd, @CommandId, @UniqueId);
end;
end
go