Back to OIM Explorer

dbo.QER_FGIReasonTypeForACCProduct

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 1.092 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

SQL44 lines
1CREATE FUNCTION dbo.QER_FGIReasonTypeForACCProduct(2  @UID_ACCProduct 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)) AS ApproveReasonType, max(a.DenyReasonType) | max(isnull(ag.DenyReasonType32    , 0)) AS DenyReasonType, max(a.OrderReasonType) | max(isnull(ag.OrderReasonType, 0)) AS OrderReasonType33  FROM AccProduct a34  LEFT35  OUTER36  JOIN AccProductGroupCollection ac37    ON a.UID_AccProductGroup = ac.UID_AccProductGroupChild38  LEFT39  OUTER40  JOIN AccProductGroup ag41    ON ac.UID_AccProductGroupParent = ag.UID_AccProductGroup42  WHERE43    a.UID_AccProduct = @UID_ACCProduct) AS y) AS x)44END
Open raw exported source
SQL ยท Raw9 lines
1   create   function dbo.QER_FGIReasonTypeForACCProduct(@UID_ACCProduct varchar(38) , @TypeOfReasonType varchar(16)  ) returns int as begin return2( select case @TypeOfReasonType when 'Approve' then x.ApproveReasonType when 'Deny' then x.DenyReasonType else x.OrderReasonType end from ( select case3 y.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)) as ApproveReasonType , max(a.DenyReasonType) | max(isnull(ag.DenyReasonType,0)) as DenyReasonType , max(a.OrderReasonType) | 6max(isnull(ag.OrderReasonType,0)) as OrderReasonType from AccProduct a left outer join AccProductGroupCollection ac on a.UID_AccProductGroup = ac.UID_AccProductGroupChild7 left outer join AccProductGroup ag on ac.UID_AccProductGroupParent = ag.UID_AccProductGroup where a.UID_AccProduct = @UID_ACCProduct ) as y ) as x ) end8 9