dbo.QBM_FGIJobQueueExistsPending
Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB
Interpretation
- Database function. Usually supports views, validation, or calculated predicates; look at referenced-by entries for callers.
Relations
- No extracted relations.
Typed Edges
- No typed edges extracted for this source.
References
- No direct source references extracted.
Referenced By
- No direct source references extracted.
Complete Source
1CREATE FUNCTION dbo.QBM_FGIJobQueueExistsPending(2 @XObjectKey varchar(138),3 @ParamInPattern nvarchar(1000)4) RETURNS BIT5 WITH schemabinding6AS7BEGIN8 DECLARE @PIPattern nvarchar(1000)9 DECLARE @pendingProcessFound BIT = 010 SELECT @PIPattern = @ParamInPattern11 IF ISNULL(@PIPattern,12 N '') = N ''13 BEGIN14 RETURN(@pendingProcessFound)15 END16 IF17 LEFT(@PIPattern,18 1) <> N '%'19 BEGIN20 SELECT @PIPattern = N '%' + @PIPattern21 END22 IF23 RIGHT(@PIPattern,24 1) <> N '%'25 BEGIN26 SELECT @PIPattern = @PIPattern + N '%'27 END28 IF EXISTS(29 SELECT TOP 1 130 FROM(31 SELECT UID_Tree32 FROM dbo.JobQueue q33 WITH(nolock)34 JOIN dbo.QBMElementAffectedByJob ebj35 ON q.UID_Job = ebj.UID_Job36 WHERE37 ebj.ObjectKeyAffected = @XObjectKey AND q.ParamIN LIKE @PIPattern38 GROUP BY q.UID_Tree) AS x39 JOIN(40 SELECT41 q2.UID_Tree, SUM(CASE q2.Ready2EXE42 WHEN N 'TRUE' THEN43 144 WHEN N 'FALSE' THEN45 146 ELSE 047 END) AS CountNotRunning, COUNT(*) AS CountAll48 FROM dbo.JobQueue q249 WITH(nolock)50 GROUP BY q2.UID_Tree) AS y51 ON x.UID_Tree = y.UID_Tree52 WHERE53 y.CountNotRunning = y.CountAll)54 BEGIN55 SELECT @pendingProcessFound = 156 END57 endLabel:58 RETURN(@pendingProcessFound)59END
Open raw exported source
1 create function dbo.QBM_FGIJobQueueExistsPending ( @XObjectKey varchar(138) , @ParamInPattern nvarchar(1000) ) returns bit with schemabinding2 as begin declare @PIPattern nvarchar(1000) DECLARE @pendingProcessFound BIT = 0 select @PIPattern = @ParamInPattern if ISNULL(@PIPattern, N'') = N'' 3begin return(@pendingProcessFound) end if LEFT(@PIPattern, 1) <> N'%' begin select @PIPattern = N'%' + @PIPattern end if right(@PIPattern, 1) <> N'%'4 begin select @PIPattern = @PIPattern + N'%' end IF EXISTS ( select top 1 1 FROM ( SELECT UID_Tree FROM dbo.JobQueue q with (nolock) join dbo.QBMElementAffectedByJob5 ebj on q.UID_Job = ebj.UID_Job WHERE ebj.ObjectKeyAffected = @XObjectKey AND q.ParamIN like @PIPattern GROUP BY q.UID_Tree ) AS x join (select q2.UID_Tree6 , SUM(CASE q2.Ready2EXE WHEN N'TRUE' THEN 1 WHEN N'FALSE' THEN 1 ELSE 0 END) AS CountNotRunning ,COUNT(*) AS CountAll from dbo.JobQueue q2 with (nolock7) group by q2.UID_Tree ) as y on x.UID_Tree = y.UID_Tree WHERE y.CountNotRunning = y.CountAll ) BEGIN SELECT @pendingProcessFound = 1 END endLabel: RETURN8 (@pendingProcessFound) end 9