dbo.ATT_FGIReasonTypeForAttCase
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.ATT_FGIReasonTypeForAttCase(2 @UID_AttesttationCase varchar(38),3 @TypeOfReasonType varchar(16)4) RETURNS int5AS6BEGIN7 RETURN(8 SELECT CASE @TypeOfReasonType9 WHEN 'Approve' THEN10 isnull(x.ApproveReasonType, 0)11 ELSE isnull(x.DenyReasonType, 0)12 END13 FROM(14 SELECT CASE y.ApproveReasonType15 WHEN 3 THEN16 217 ELSE y.ApproveReasonType18 END AS ApproveReasonType, CASE y.DenyReasonType19 WHEN 3 THEN20 221 ELSE y.DenyReasonType22 END AS DenyReasonType23 FROM(24 SELECT25 max(ap.ApproveReasonType) | max(isnull(wst.ApproveReasonType, 0)) AS ApproveReasonType, max(ap.DenyReasonType) | max(isnull(wst.DenyReasonType26 , 0)) AS DenyReasonType27 FROM AttestationCase ac28 JOIN AttestationPolicy ap29 ON ac.UID_AttestationPolicy = ap.UID_AttestationPolicy30 LEFT31 OUTER32 JOIN AttestationHelper h33 ON ac.UID_AttestationCase = h.UID_AttestationCase AND ac.DecisionLevel = h.LevelNumber34 LEFT35 OUTER36 JOIN QERWorkingStep wst37 ON h.UID_QERWorkingStep = wst.UID_QERWorkingStep38 WHERE39 ac.UID_AttestationCase = @UID_AttesttationCase) AS y) AS x)40END
Open raw exported source
1 create function dbo.ATT_FGIReasonTypeForAttCase(@UID_AttesttationCase varchar(38) , @TypeOfReasonType varchar(16) ) returns int as begin return2( select case @TypeOfReasonType when 'Approve' then isnull(x.ApproveReasonType, 0) else isnull(x.DenyReasonType, 0) end from ( select case y.ApproveReasonType3 when 3 then 2 else y.ApproveReasonType end as ApproveReasonType , case y.DenyReasonType when 3 then 2 else y.DenyReasonType end as DenyReasonType from4 ( select max(ap.ApproveReasonType) | max(isnull(wst.ApproveReasonType,0)) as ApproveReasonType , max(ap.DenyReasonType) | max(isnull(wst.DenyReasonType5,0)) as DenyReasonType from AttestationCase ac join AttestationPolicy ap on ac.UID_AttestationPolicy = ap.UID_AttestationPolicy left outer join AttestationHelper6 h on ac.UID_AttestationCase = h.UID_AttestationCase and ac.DecisionLevel = h.LevelNumber left outer join QERWorkingStep wst on h.UID_QERWorkingStep = 7wst.UID_QERWorkingStep where ac.UID_AttestationCase = @UID_AttesttationCase ) as y ) as x ) end 8