UFN_EXCHANGECONTACTBATCHASSIGNMENT_RESOLVEDASSIGNMENTS
Returns contact batch appuser and owner appuser id mappings based on the appuser selection ids.
Return
Return Type |
---|
table |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@EXCHANGEDOWNLOADPROCESSID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_EXCHANGECONTACTBATCHASSIGNMENT_RESOLVEDASSIGNMENTS
(
@EXCHANGEDOWNLOADPROCESSID uniqueidentifier
)
returns @ASSIGNMENTS table(APPUSERID uniqueidentifier, OWNERAPPUSERID uniqueidentifier)
as
begin
declare ASSIGNMENTCURSOR cursor local fast_forward for
select
APPUSERIDSETREGISTERID,
OWNERAPPUSERID
from
dbo.EXCHANGECONTACTBATCHASSIGNMENT
order by
EXCHANGECONTACTBATCHASSIGNMENT.DATEADDED;
declare @SELECTIONID uniqueidentifier;
declare @OWNERAPPUSERID uniqueidentifier;
open ASSIGNMENTCURSOR;
fetch next from ASSIGNMENTCURSOR into @SELECTIONID, @OWNERAPPUSERID;
declare @SELECTION TABLE (ID UNIQUEIDENTIFIER NOT NULL PRIMARY KEY);
while @@FETCH_STATUS = 0 begin
insert into @SELECTION (ID) select ID from dbo.UFN_IDSETREADER_GETRESULTS_GUID(@SELECTIONID);
insert into @ASSIGNMENTS(APPUSERID, OWNERAPPUSERID) select SELECTION.ID, @OWNERAPPUSERID from @SELECTION as SELECTION where SELECTION.ID not in(select APPUSERID from @ASSIGNMENTS)
delete from @SELECTION;
fetch next from ASSIGNMENTCURSOR into @SELECTIONID, @OWNERAPPUSERID;
end
--When a cursor is used, it should be explicitly closed/deallocated in case of blocking or USP running long
close ASSIGNMENTCURSOR
deallocate ASSIGNMENTCURSOR
return
end