USP_SPONSORSHIPOPPORTUNITY_UNRESERVE_MAXKEY
Unreserves opportunities due to a max key number lower than the number of reserved opportunities.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@KEYID | uniqueidentifier | IN | |
@CHANGEAGENTID | uniqueidentifier | IN | |
@MAXKEY | int | IN | |
@SUCCESSCOUNT | int | INOUT | |
@EXCEPTIONCOUNT | int | INOUT |
Definition
Copy
create procedure dbo.USP_SPONSORSHIPOPPORTUNITY_UNRESERVE_MAXKEY
(
@KEYID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@MAXKEY int,
@SUCCESSCOUNT int = 0 output,
@EXCEPTIONCOUNT int = 0 output
)
as begin
set nocount on;
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
set @SUCCESSCOUNT = 0
set @EXCEPTIONCOUNT = 0
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
begin try
-- Updating the children by deleting the reservationkey
update top(@MAXKEY) dbo.SPONSORSHIPOPPORTUNITY
set RESERVATIONKEYID = null, AVAILABILITYCODE = 0, CHANGEDBYID = @CHANGEAGENTID, DATECHANGED = @CURRENTDATE
where RESERVATIONKEYID = @KEYID
set @SUCCESSCOUNT = @@ROWCOUNT
end try
begin catch
exec dbo.USP_RAISE_ERROR;
set @EXCEPTIONCOUNT = @EXCEPTIONCOUNT + 1
return 1;
end catch
return 0;
end