USP_DATAFORMTEMPLATE_EDIT_HOUSEHOLDMANAGENAMEFORMAT
The save procedure used by the edit dataform template "Household Global Name Format Edit Data Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@NAMEFORMATFUNCTIONID | uniqueidentifier | IN | Name format |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_HOUSEHOLDMANAGENAMEFORMAT (
@CHANGEAGENTID uniqueidentifier = null,
@NAMEFORMATFUNCTIONID uniqueidentifier
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
-- handle updating the data
update dbo.HOUSEHOLDINFO set
NAMEFORMATFUNCTIONID = @NAMEFORMATFUNCTIONID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
-- If this is the first time this form is saved, the row needs to be created
if @@ROWCOUNT = 0
begin
declare @ID uniqueidentifier
set @ID = newid()
insert into dbo.HOUSEHOLDINFO
(
ID,
NAMEFORMATFUNCTIONID,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
@ID,
@NAMEFORMATFUNCTIONID,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
)
end
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;