Back to OIM Explorer

dbo.QER_P30907EB9FB8232867B_func

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 4.496 characters

Interpretation

  • Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.

Relations

  • No extracted relations.

Typed Edges

  • references source dbo.QBM_FCVStringToIndent source text reference
  • references source dbo.QBM_FGICodeName source text reference
  • references source dbo.QBM_PFunctionDrop source text reference
  • references source dbo.QBM_PGICountTablesUsedByCode source text reference

Complete Source

SQL172 lines
1CREATE PROCEDURE QER_P30907EB9FB8232867B_func(2  @Statements QBM_YCursorbuffer READONLY,3  @UsageArea char(1),4  @FunctionName varchar(30),5  @UID_PWODecisionRule varchar(38),6  @Komplett nvarchar(max) OUTPUT7)8AS9BEGIN10  DECLARE @OpenParenthesis nvarchar(max)11  DECLARE @CountReferencedTables int = 012  DECLARE @LimitOfTableReferences int = 80013  DECLARE @MakeInlineFunction BIT = 114  DECLARE @Muster nvarchar(max)15  DECLARE @Body nvarchar(max) = N ''16  DECLARE @DebugSwitch int = 017  DECLARE @DebugLevel char(1) = 'W'18  DECLARE @MyTempElementName varchar(30) =19  LEFT(CONCAT('TST_FTemporaryElement', reverse(dbo.QBM_FGICodeName('V', NEWID()))),20  30)21  SELECT22    @OpenParenthesis = CONCAT('create function dbo.',23    @MyTempElementName,24    '  (',25  CASE @UsageArea26    WHEN 'I' THEN27  '@uid_PersonWantsOrg varchar(38)'28  ELSE '@uid_AttestationCase varchar(38)'29  END,30  '	, @UID_QERWorkingStep varchar(38) )31																				returns table 32																				as33																				return (34																				'35  )36  EXEC @CountReferencedTables = QBM_PGICountTablesUsedByCode @Statements,37    @CodeName = @MyTempElementName,38    @CodeType = 'function',39    @OpenParenthesis = @OpenParenthesis,40    @CloseParenthesis = '41																					)42																					'43  IF @CountReferencedTables > @LimitOfTableReferences44  BEGIN45    SELECT @MakeInlineFunction = 046  END47  EXEC QBM_PFunctionDrop @MyTempElementName48  IF @MakeInlineFunction = 149  BEGIN50    SELECT51      @Muster = 'create function dbo.%FunctionName% (52								%parameters%53							)54		returns table55	-- definition for rule 	%UID_PWODecisionRule%					56	as57	return 58	(59		select z.UID_Person as UID_Person60			%ReturnPWOOrigin%61			, convert(varchar(128), ''decision rule %UID_PWODecisionRule%'')  as SourceInfo62		from (6364	%body%6566			) as y join Person z on y.UID_Person = z.UID_Person 67								and z.IsInActive = 0	68		group by z.UID_Person					69	)70	'71  END72  ELSE73  BEGIN74    SELECT75      @Muster = 'create function dbo.%FunctionName% (76								%parameters%77							)78	returns @erg table ( UID_Person varchar(38) collate database_default79					,  UID_PWORulerOrigin varchar(38) collate database_default80					, SourceInfo varchar(128) collate database_default81					)82	-- definition for rule 	%UID_PWODecisionRule%					83	as84	begin85		declare @Puffer QBM_YParameterList8687	%body%8889	insert into @erg(UID_Person, UID_PWORulerOrigin, SourceInfo)90	select z.UID_Person as UID_Person91		,  max(convert(varchar(38), y.UID_PWORulerOrigin)) as UID_PWORulerOrigin92		, convert(varchar(128), ''decision rule %UID_PWODecisionRule%'')  as SourceInfo93	from (94			select p.Parameter1 as UID_Person, p.Parameter2 as UID_PWORulerOrigin95				from @Puffer p96					97		) as y  join Person z on y.UID_Person = z.UID_Person 98							and z.IsInActive = 0	99		group by z.UID_Person					100101	 return102	end103104	'105  END106  IF @MakeInlineFunction = 1107  BEGIN108    SELECT109      @Body = string_agg(CONCAT('select x.UID_Person, x.UID_PWORulerOrigin', '110	from (111		 -- code from PWODecisionRuleRulerDetect: ',112      d.UID1, '113	', dbo.QBM_FCVStringToIndent(d.ContentFull, 3), '114		 -- / code from PWODecisionRuleRulerDetect115		) as x	116		'),117      '118	union all119')120    FROM @Statements d121  END122  ELSE123  BEGIN124    SELECT125      @Body = string_agg(CONCAT('insert into @Puffer(Parameter1, Parameter2)126		 -- code from PWODecisionRuleRulerDetect: ',127      d.UID1, '128	', dbo.QBM_FCVStringToIndent(d.ContentFull, 3), '129		 -- / code from PWODecisionRuleRulerDetect130		'),131      '132')133    FROM @Statements d134  END135  IF @DebugSwitch > 0136  BEGIN137    print '#####################'138    SELECT @Body print '#####################'139  END140  IF isnull(@Body,141  '') = ''142  BEGIN143    SELECT144      @Muster = 'create function dbo.%FunctionName% (145							%parameters%146						)147	returns table148-- definition for rule 	%UID_PWODecisionRule%					149as150return 151(152	select convert(varchar(38), null) as UID_Person, convert(varchar(38), null) as UID_PWORulerOrigin153		, convert(varchar(128), ''decision rule %UID_PWODecisionRule%'')  as SourceInfo154155)156'157  END158  SELECT159    @Komplett = replace(replace(replace(replace(REPLACE(@Muster, '%FunctionName%', @FunctionName),160    '%parameters%', CASE @UsageArea161    WHEN 'I' THEN162    '@uid_PersonWantsOrg varchar(38)'163  ELSE '@uid_AttestationCase varchar(38)'164  END + '	, @UID_QERWorkingStep varchar(38)'), '%ReturnPWOOrigin%', ',  max(convert(varchar(38), y.UID_PWORulerOrigin)) as UID_PWORulerOrigin'),165  '%Body%', dbo.qbm_fcvstringtoindent(@Body, 3)),166  '%UID_PWODecisionRule%',167  @UID_PWODecisionRule)168  IF @DebugSwitch > 0169  BEGIN170    print @komplett171  END172END
Open raw exported source
SQL ยท Raw100 lines
1 create   procedure QER_P30907EB9FB8232867B_func  ( @Statements QBM_YCursorbuffer readonly , @UsageArea char(1) , @FunctionName varchar(30) , @UID_PWODecisionRule2 varchar(38) , @Komplett nvarchar(max) output  ) as begin declare @OpenParenthesis nvarchar(max) declare @CountReferencedTables int = 0 declare @LimitOfTableReferences3 int = 800 declare @MakeInlineFunction bit = 1 declare @Muster nvarchar(max) declare @Body nvarchar(max) = N'' declare @DebugSwitch int = 0 declare @DebugLevel4 char(1) = 'W' declare @MyTempElementName varchar(30) = left(concat('TST_FTemporaryElement', reverse(dbo.QBM_FGICodeName('V', NEWID()) )), 30) select @OpenParenthesis5 = concat('create function dbo.',@MyTempElementName,'  (' , case @UsageArea when 'I' then '@uid_PersonWantsOrg varchar(38)' Else '@uid_AttestationCase varchar(38)'6 end , '	, @UID_QERWorkingStep varchar(38) )7																				returns table 8																				as9																				return (10																				'11 ) exec @CountReferencedTables = QBM_PGICountTablesUsedByCode @Statements , @CodeName = @MyTempElementName , @CodeType = 'function' , @OpenParenthesis 12= @OpenParenthesis , @CloseParenthesis = '13																					)14																					' if @CountReferencedTables > @LimitOfTableReferences begin select15 @MakeInlineFunction = 0 end   exec QBM_PFunctionDrop @MyTempElementName if @MakeInlineFunction = 1 begin select @Muster = 'create function dbo.%FunctionName% (16								%parameters%17							)18		returns table19	-- definition for rule 	%UID_PWODecisionRule%					20	as21	return 22	(23		select z.UID_Person as UID_Person24			%ReturnPWOOrigin%25			, convert(varchar(128), ''decision rule %UID_PWODecisionRule%'')  as SourceInfo26		from (2728	%body%2930			) as y join Person z on y.UID_Person = z.UID_Person 31								and z.IsInActive = 0	32		group by z.UID_Person					33	)34	'35 end else begin select @Muster = 'create function dbo.%FunctionName% (36								%parameters%37							)38	returns @erg table ( UID_Person varchar(38) collate database_default39					,  UID_PWORulerOrigin varchar(38) collate database_default40					, SourceInfo varchar(128) collate database_default41					)42	-- definition for rule 	%UID_PWODecisionRule%					43	as44	begin45		declare @Puffer QBM_YParameterList4647	%body%4849	insert into @erg(UID_Person, UID_PWORulerOrigin, SourceInfo)50	select z.UID_Person as UID_Person51		,  max(convert(varchar(38), y.UID_PWORulerOrigin)) as UID_PWORulerOrigin52		, convert(varchar(128), ''decision rule %UID_PWODecisionRule%'')  as SourceInfo53	from (54			select p.Parameter1 as UID_Person, p.Parameter2 as UID_PWORulerOrigin55				from @Puffer p56					57		) as y  join Person z on y.UID_Person = z.UID_Person 58							and z.IsInActive = 0	59		group by z.UID_Person					6061	 return62	end6364	'65 end if @MakeInlineFunction = 1 begin select @Body = string_agg(concat( 'select x.UID_Person, x.UID_PWORulerOrigin' , '66	from (67		 -- code from PWODecisionRuleRulerDetect: '68 , d.UID1  , '69	' , dbo.QBM_FCVStringToIndent(d.ContentFull , 3) , '70		 -- / code from PWODecisionRuleRulerDetect71		) as x	72		' )  ,  '73	union all74'75 )  from @Statements  d  end else begin select @Body = string_agg(concat( 'insert into @Puffer(Parameter1, Parameter2)76		 -- code from PWODecisionRuleRulerDetect: '77 , d.UID1  , '78	' , dbo.QBM_FCVStringToIndent(d.ContentFull , 3) , '79		 -- / code from PWODecisionRuleRulerDetect80		' )  ,  '81' )  from @Statements82  d end  if @DebugSwitch > 0 begin print '#####################' select @Body print '#####################' end if isnull(@Body, '') = '' begin select 83@Muster = 'create function dbo.%FunctionName% (84							%parameters%85						)86	returns table87-- definition for rule 	%UID_PWODecisionRule%					88as89return 90(91	select convert(varchar(38), null) as UID_Person, convert(varchar(38), null) as UID_PWORulerOrigin92		, convert(varchar(128), ''decision rule %UID_PWODecisionRule%'')  as SourceInfo9394)95'96 end  select @Komplett = replace(replace(replace(replace(REPLACE(@Muster , '%FunctionName%', @FunctionName) , '%parameters%', case @UsageArea when 'I' 97then '@uid_PersonWantsOrg varchar(38)' Else '@uid_AttestationCase varchar(38)' end + '	, @UID_QERWorkingStep varchar(38)') , '%ReturnPWOOrigin%', ',  max(convert(varchar(38), y.UID_PWORulerOrigin)) as UID_PWORulerOrigin'98)     , '%Body%', dbo.qbm_fcvstringtoindent( @Body, 3)) , '%UID_PWODecisionRule%', @UID_PWODecisionRule) if @DebugSwitch > 0 begin print @komplett end 99end 100