UFN_EMAIL_ISCURRENTPROCESSWORKINGONJOB
Checks if any current email process is working on job.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@QUEUEID | uniqueidentifier | IN | |
@INSTANCEID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_EMAIL_ISCURRENTPROCESSWORKINGONJOB(@QUEUEID uniqueidentifier, @INSTANCEID uniqueidentifier)
returns bit
with execute as owner
as begin
declare @SQL nvarchar(1000);
declare @NUMBER integer = 0;
declare @TABLENAME nvarchar(255);
set @TABLENAME = dbo.UFN_GENERALPURPOSEEMAIL_GETDATATABLENAME(@QUEUEID)
set @SQL = 'if object_id(''' + @TABLENAME + ''') is not null select @NUMBER = count(*) from ' + @TABLENAME + ' where INSTANCEID = ''' + cast(@INSTANCEID as nvarchar(36)) + '''';
exec sp_executesql @SQL, N'@NUMBER integer output', @NUMBER output;
declare @ISCURRENTPROCESSWORKING bit;
if @NUMBER < 1
begin
set @ISCURRENTPROCESSWORKING = 0;
end
else
begin
set @ISCURRENTPROCESSWORKING = 1;
end
return @ISCURRENTPROCESSWORKING;
end