USP_CONSTITUENCYDEFINITION_MARKACTIVE
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | |
@CHANGEAGENTID | uniqueidentifier | IN |
Definition
Copy
CREATE procedure dbo.USP_CONSTITUENCYDEFINITION_MARKACTIVE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier
)
as
set nocount on;
declare @CURRENTDATE datetime = getdate();
begin try
declare @ISCONSTITUENCYCODEID bit = 0;
if exists (select 1 from dbo.CONSTITUENCYCODE where ID = @ID)
begin
set @ISCONSTITUENCYCODEID = 1;
end
update dbo.CONSTITUENCYDEFINITION
set
ISACTIVE = 1,
DATECHANGED = @CURRENTDATE,
CHANGEDBYID = @CHANGEAGENTID
where
ID = @ID;
--update the corresponding constituency code record
if @ISCONSTITUENCYCODEID = 1
begin
update dbo.CONSTITUENCYCODE set
ACTIVE = 1,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
ID = @ID;
end
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch