UFN_REVENUE_GETSOLICITORS_LIST
Returns a list of solicitors for a revenue detail record.
Return
Return Type |
---|
nvarchar(1000) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@REVENUEID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_REVENUE_GETSOLICITORS_LIST
(
@REVENUEID uniqueidentifier
)
returns nvarchar(1000)
as
begin
declare @LIST nvarchar(1000)
declare @SEPARATOR nvarchar(2);
declare @NAME nvarchar(255);
declare SOLICITORCURSOR cursor local fast_forward for
select
CONSTITUENT.NAME
from dbo.UFN_REVENUE_GETSOLICITORS(@REVENUEID) as [SOL]
inner join dbo.CONSTITUENT on CONSTITUENT.ID = [SOL].CONSTITUENTID
order by [SOL].SEQUENCE;
open SOLICITORCURSOR;
fetch next from SOLICITORCURSOR into @NAME;
set @LIST = N'';
set @SEPARATOR = N'';
while @@FETCH_STATUS = 0
begin
set @LIST = @LIST + @SEPARATOR + @NAME;
set @SEPARATOR = '; ';
fetch next from SOLICITORCURSOR into @NAME;
end
--When a cursor is used, it should be explicitly closed/deallocated in case of blocking or USP running long
close SOLICITORCURSOR;
deallocate SOLICITORCURSOR;
return @LIST;
end