USP_SPONSORSHIPOPPORTUNITYRESERVEPROCESS_DELETE
Executes the "Sponsorship Opportunity Reserve Business Process: 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. |
Definition
Copy
CREATE procedure dbo.USP_SPONSORSHIPOPPORTUNITYRESERVEPROCESS_DELETE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier
)
as
set nocount on;
begin try
declare @STATUS int;
declare @RESERVATIONSTATUSID uniqueidentifier;
declare @RESERVECOUNT integer;
select @STATUS = SP.STATUSCODE, @RESERVATIONSTATUSID = SP.ID
from dbo.SPONSORSHIPOPPORTUNITYRESERVATIONSTATUS SP
where SP.OPPORTUNITYRESERVATIONKEYID = @ID
--Bug 169795 AlexLa We can allow the deletion of the process if all children are deleted.
select @RESERVECOUNT = count(*)
from dbo.SPONSORSHIPOPPORTUNITY
where SPONSORSHIPOPPORTUNITY.RESERVATIONKEYID = @ID
if @STATUS = 1 and @RESERVECOUNT > 0
begin
raiserror('BBERR_PROCESSHASACTIVEKEY',13,1)
end
--Bug#507865 - We can't allow deletion if uncommitted sponsorship batch contain this key
if exists (select 1 from BATCHSPONSORSHIP
inner join BATCH on BATCH.ID = BATCHSPONSORSHIP.BATCHID
where BATCH.STATUSCODE = 0 and BATCHSPONSORSHIP.RESERVATIONKEYID = @ID)
begin
raiserror('BBERR_PROCESSHASUNCOMMITEDSPONSORSHIPBATCH',13,1)
end
-- delete reservation status table entry
exec dbo.USP_SPONSORSHIPOPPORTUNITYRESERVATIONSTATUS_DELETEBYID_WITHCHANGEAGENTID @RESERVATIONSTATUSID, @CHANGEAGENTID;
--delete main reservation table entry
exec dbo.USP_SPONSORSHIPOPPORTUNITYRESERVEPROCESS_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
return 0;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch