USP_ORDERPROGRAMLASTTICKETINSTANCES_DELETE
Executes the "Order Program Last Ticket Instances Delete" record operation.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | Input parameter indicating the ID of the record being deleted. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the delete. |
@PROGRAMID | uniqueidentifier | IN |
Definition
Copy
create procedure dbo.USP_ORDERPROGRAMLASTTICKETINSTANCES_DELETE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier,
@PROGRAMID uniqueidentifier = null
)
as begin
declare @e int;
declare @contextCache varbinary(128);
set @contextCache = CONTEXT_INFO();
if not @CHANGEAGENTID is null
set CONTEXT_INFO @CHANGEAGENTID
delete from dbo.TICKETPRINTINFO from
dbo.TICKETPRINTINFO inner join
(select TICKETPRINTINFO.TICKETID, MAX(TICKETPRINTINFO.SEQUENCEID) SEQUENCEID
from
dbo.SALESORDER inner join dbo.SALESORDERITEM on
SALESORDER.ID = SALESORDERITEM.SALESORDERID
inner join dbo.SALESORDERITEMTICKET on
SALESORDERITEM.ID = SALESORDERITEMTICKET.ID
inner join dbo.TICKET on
SALESORDERITEMTICKET.ID = TICKET.SALESORDERITEMTICKETID
inner join dbo.TICKETPRINTINFO on
TICKET.ID = TICKETPRINTINFO.TICKETID
where
SALESORDER.ID = @ID and
(@PROGRAMID is null or SALESORDERITEMTICKET.PROGRAMID = @PROGRAMID)
group by
TICKETPRINTINFO.TICKETID) TICKETINSTANCE on
TICKETPRINTINFO.TICKETID = TICKETINSTANCE.TICKETID and
TICKETPRINTINFO.SEQUENCEID = TICKETINSTANCE.SEQUENCEID
if not @contextCache is null
set CONTEXT_INFO @contextCache
select @e=@@error;
if @e<>0 return -456; --always return non-zero sp result if an error occurs
return 0;
end