Back to OIM Explorer

dbo.QER_FGIReasonTypeForPWO

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 1.489 characters

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

SQL57 lines
1CREATE FUNCTION dbo.QER_FGIReasonTypeForPWO(2  @UID_PersonWantsOrg varchar(38),3  @TypeOfReasonType varchar(16)4) RETURNS int5AS6BEGIN7  RETURN(8  SELECT CASE @TypeOfReasonType9  WHEN 'Approve' THEN10  x.ApproveReasonType11  WHEN 'Deny' THEN12  x.DenyReasonType13  ELSE x.OrderReasonType14  END15  FROM(16  SELECT CASE y.ApproveReasonType17  WHEN 3 THEN18  219  ELSE y.ApproveReasonType20  END AS ApproveReasonType, CASE y.DenyReasonType21  WHEN 3 THEN22  223  ELSE y.DenyReasonType24  END AS DenyReasonType, CASE y.OrderReasonType25  WHEN 3 THEN26  227  ELSE y.OrderReasonType28  END AS OrderReasonType29  FROM(30  SELECT31    max(a.ApproveReasonType) | max(isnull(ag.ApproveReasonType, 0)) | max(isnull(wst.ApproveReasonType,32    0)) AS ApproveReasonType, max(a.DenyReasonType) | max(isnull(ag.DenyReasonType, 0)) | max(isnull(wst.DenyReasonType,33    0)) AS DenyReasonType, max(a.OrderReasonType) | max(isnull(ag.OrderReasonType, 0)) AS OrderReasonType34  FROM PersonWantsOrg pwo35  JOIN BaseTree pr36    ON pwo.UID_Org = pr.UID_Org37  JOIN AccProduct a38    ON pr.UID_AccProduct = a.UID_AccProduct39  LEFT40  OUTER41  JOIN AccProductGroupCollection ac42    ON a.UID_AccProductGroup = ac.UID_AccProductGroupChild43  LEFT44  OUTER45  JOIN AccProductGroup ag46    ON ac.UID_AccProductGroupParent = ag.UID_AccProductGroup47  LEFT48  OUTER49  JOIN PWOHelperPWO h50    ON pwo.UID_PersonWantsOrg = h.UID_PersonWantsOrg AND pwo.DecisionLevel = h.LevelNumber51  LEFT52  OUTER53  JOIN QERWorkingStep wst54    ON h.UID_QERWorkingStep = wst.UID_QERWorkingStep55  WHERE56    pwo.UID_PersonWantsOrg = @UID_PersonWantsOrg) AS y) AS x)57END
Open raw exported source
SQL ยท Raw11 lines
1   create   function dbo.QER_FGIReasonTypeForPWO(@UID_PersonWantsOrg varchar(38) , @TypeOfReasonType varchar(16)  ) returns int as begin return(2 select case @TypeOfReasonType when 'Approve' then x.ApproveReasonType when 'Deny' then x.DenyReasonType else x.OrderReasonType end from ( select case 3y.ApproveReasonType when 3 then 2  else y.ApproveReasonType end as ApproveReasonType , case y.DenyReasonType when 3 then 2 else y.DenyReasonType end as4 DenyReasonType , case y.OrderReasonType when 3 then 2 else y.OrderReasonType end as OrderReasonType from ( select max(a.ApproveReasonType) | max(isnull5(ag.ApproveReasonType,0)) | max(isnull(wst.ApproveReasonType,0)) as ApproveReasonType , max(a.DenyReasonType) | max(isnull(ag.DenyReasonType,0)) | max(isnull6(wst.DenyReasonType,0)) as DenyReasonType , max(a.OrderReasonType) | max(isnull(ag.OrderReasonType,0)) as OrderReasonType from PersonWantsOrg pwo join 7BaseTree pr on pwo.UID_Org = pr.UID_Org join AccProduct a on pr.UID_AccProduct = a.UID_AccProduct left outer join AccProductGroupCollection ac on a.UID_AccProductGroup8 = ac.UID_AccProductGroupChild left outer join AccProductGroup ag on ac.UID_AccProductGroupParent = ag.UID_AccProductGroup left outer join PWOHelperPWO9 h on pwo.UID_PersonWantsOrg = h.UID_PersonWantsOrg and pwo.DecisionLevel = h.LevelNumber left outer join QERWorkingStep wst on h.UID_QERWorkingStep = 10wst.UID_QERWorkingStep where pwo.UID_PersonWantsOrg = @UID_PersonWantsOrg ) as y ) as x ) end 11