dbo.TSB_FGIPWODecisionForGroup
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
- references source dbo.QBM_FCVObjectkeyToElement source text reference
Complete Source
1CREATE FUNCTION dbo.TSB_FGIPWODecisionForGroup(2 @uid_personwantsorg varchar(38)3) RETURNS int4AS5BEGIN6 DECLARE @erg int7 SELECT @erg = 18 DECLARE @ObjectKeyOrdered varchar(138)9 DECLARE @UID_PersonOrdered varchar(38)10 DECLARE @SourceTable nvarchar(32)11 SELECT12 TOP 1 @ObjectKeyOrdered = ObjectKeyOrdered,13 @UID_PersonOrdered = UID_PersonOrdered,14 @SourceTable = dbo.QBM_FCVObjectkeyToElement('TableName',15 ObjectKeyOrdered)16 FROM personwantsorg17 WHERE18 uid_personwantsorg = @uid_personWantsorg19 SELECT20 @erg = CASE(4*sign(len(isnull(ra.UID_TSBAccountDef, ''))) + 2*sign(len(isnull(phr.UID_TSBAccountDef,21 ''))) + sign(len(isnull(pwoA.uid_personwantsorg, ''))))22 WHEN 4 THEN23 124 WHEN 5 THEN25 126 WHEN 6 THEN27 128 WHEN 7 THEN29 130 WHEN 3 THEN31 032 WHEN 2 THEN33 034 WHEN 1 THEN35 036 ELSE -137 END38 FROM personwantsorg pwo39 JOIN TSBGroupToTSBAccountDef ga40 ON pwo.ObjectKeyOrdered = @ObjectKeyOrdered AND pwo.ObjectKeyOrdered = ga.ObjectKeyGroup AND pwo.uid_personwantsorg = @uid_personWantsorg AND41 ga.BaseTableForPWO = @SourceTable42 LEFT43 OUTER44 JOIN TSBAccountDefAndAccount ra45 ON ga.UID_TSBAccountDef = ra.UID_TSBAccountDef AND ra.uid_person = @UID_PersonOrdered46 LEFT47 OUTER48 JOIN PersonHasTSBAccountDef phr49 ON ga.UID_TSBAccountDef =phr.UID_TSBAccountDef AND phr.XOrigin > 0 AND phr.XIsInEffect = 1 AND phr.uid_person = @UID_PersonOrdered50 LEFT51 OUTER52 JOIN personwantsorg pwoA53 ON pwoA.uid_personordered = @UID_PersonOrdered AND pwoA.ObjectKeyOrdered = ga.ObjectKeyTSBAccountDef AND pwoA.OrderState IN('Assigned',54 'OrderProduct',55 'OrderProlongate',56 'OrderUnsubscribe')57 RETURN(@erg)58END
Open raw exported source
1 create function dbo.TSB_FGIPWODecisionForGroup (@uid_personwantsorg varchar(38)) returns int as begin declare @erg int select @erg = 1 declare2 @ObjectKeyOrdered varchar(138) declare @UID_PersonOrdered varchar(38) declare @SourceTable nvarchar(32) select top 1 @ObjectKeyOrdered = ObjectKeyOrdered3, @UID_PersonOrdered = UID_PersonOrdered, @SourceTable = dbo.QBM_FCVObjectkeyToElement('TableName', ObjectKeyOrdered) from personwantsorg where uid_personwantsorg4 = @uid_personWantsorg select @erg = case ( 4*sign(len(isnull(ra.UID_TSBAccountDef, ''))) + 2*sign(len(isnull(phr.UID_TSBAccountDef,''))) + sign(len(isnull5(pwoA.uid_personwantsorg, ''))) ) when 4 then 1 when 5 then 1 when 6 then 1 when 7 then 1 when 3 then 0 when 2 then 0 when 1 then 0 else -1 end from6 personwantsorg pwo join TSBGroupToTSBAccountDef ga on pwo.ObjectKeyOrdered = @ObjectKeyOrdered and pwo.ObjectKeyOrdered = ga.ObjectKeyGroup and pwo.uid_personwantsorg7 = @uid_personWantsorg and ga.BaseTableForPWO = @SourceTable left outer join TSBAccountDefAndAccount ra on ga.UID_TSBAccountDef = ra.UID_TSBAccountDef8 and ra.uid_person = @UID_PersonOrdered left outer join PersonHasTSBAccountDef phr on ga.UID_TSBAccountDef =phr.UID_TSBAccountDef and phr.XOrigin > 0 9and phr.XIsInEffect = 1 and phr.uid_person = @UID_PersonOrdered left outer join personwantsorg pwoA on pwoA.uid_personordered = @UID_PersonOrdered and10 pwoA.ObjectKeyOrdered = ga.ObjectKeyTSBAccountDef and pwoA.OrderState in ('Assigned', 'OrderProduct', 'OrderProlongate', 'OrderUnsubscribe') return11 (@erg) end 12