USP_DATAFORMTEMPLATE_SAVE_SALESORDER_RESERVEDITEM
The save procedure used by the edit dataform template "Sales Order Reserved Item Edit Data Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@SALESORDERID | uniqueidentifier | IN | Sales Order ID |
@SECONDSUNTILEXPIRATION | int | IN | Seconds Until Expiration |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_SAVE_SALESORDER_RESERVEDITEM
(
@ID uniqueidentifier,
@SALESORDERID uniqueidentifier,
@SECONDSUNTILEXPIRATION int,
@CHANGEAGENTID uniqueidentifier = null
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = current_timestamp
begin try
-- handle inserting the data
if exists(select 1 from dbo.[SALESORDERITEM] with (nolock) where [ID] = @ID)
begin
merge dbo.SALESORDERRESERVEDITEM as target
using (SELECT @ID as ID) as source
on (target.ID = source.ID)
when matched then
update
set
[CHANGEDBYID] = @CHANGEAGENTID,
[DATECHANGED] = @CURRENTDATE,
[SECONDSUNTILEXPIRATION] = @SECONDSUNTILEXPIRATION
when not matched then
insert
(
ID,
SALESORDERID,
SECONDSUNTILEXPIRATION,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
@ID,
@SALESORDERID,
@SECONDSUNTILEXPIRATION,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
);
end
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0