dbo.QBM_ZPrepropGenerateFunction
Stored ProcedureSQL_STORED_PROCEDURESandbox DB
Interpretation
- Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.
- DBQueue relation detected. Follow the task procedure and referenced-by list for async processing.
Relations
- Single DBQueue insert -> QBM-K-PrepropAll / QBM_ZPrePropAll at line 38
- References QBM_PDBQueueInsert_Single
Typed Edges
- queues DBQueue task QBM_ZPrePropAll at line 38 Single DBQueue insert -> QBM-K-PrepropAll / QBM_ZPrePropAll at line 38
- references source dbo.QBM_FGIDBOwner source text reference
- references source dbo.QBM_FGIPrepropConditionDeactiv source text reference
- references source dbo.QBM_FSQRemoveComment source text reference
- references source dbo.QBM_FSQRemoveComment_i source text reference
- references source dbo.QBM_FSQStringAsLiteral source text reference
- references source dbo.QBM_PDBQueueInsert_Single source text reference
- references source dbo.QBM_PExecuteSQLWithRetry_LLP source text reference
- references source dbo.QBM_PPrePropCheckExpression source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
- queues DBQueue task QBM-K-PrepropAll -> QBM_ZPrePropAll QBM_PDBQueueInsert_Single 'QBM-K-PrepropAll' , '', '', @GenProcID end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH ende: return end
References
- dbo.QBM_FGIDBOwner
- dbo.QBM_FGIPrepropConditionDeactiv
- dbo.QBM_FSQRemoveComment
- dbo.QBM_FSQRemoveComment_i
- dbo.QBM_FSQStringAsLiteral
- dbo.QBM_PDBQueueInsert_Single
- dbo.QBM_PExecuteSQLWithRetry_LLP
- dbo.QBM_PPrePropCheckExpression
- dbo.QBM_PSessionErrorAdd
Referenced By
- No direct source references extracted.
Complete Source
1CREATE PROCEDURE QBM_ZPrepropGenerateFunction(2 @SlotNumberDummy int,3 @dummy1 varchar(38),4 @dummy2 varchar(38),5 @dummyGenProcID varchar(38)6)7AS8BEGIN9 DECLARE @Props QBM_YParameterList10 DECLARE @Preproperfuellt nvarchar(max)11 DECLARE @tablename varchar(30)12 DECLARE @Query nvarchar(max) = 'select '''' as Condition'13 DECLARE @PreProcessorCondition nvarchar(max)14 DECLARE @IsDeactivated BIT15 DECLARE @FunctionName varchar(30) = 'QBM_FGIPrepropConditionDeactiv'16 DECLARE @FunctionBody nvarchar(max) = '17create or alter function dbo.' + @FunctionName + ' (@PreProcessorCondition nvarchar(max)18 )19 returns bit20 with schemabinding21 as22 begin23 return( case isnull(@PreProcessorCondition, '''')24 when '''' then 0'25 DECLARE @DebugSwitch int = 026 DECLARE @GenProcID varchar(38) = newid()27 DECLARE @OldCode nvarchar(max)28 DECLARE @ElementLast int29 DECLARE @ElementBufferMulti QBM_YCursorBuffer30 DECLARE @ElementCount int31 DECLARE @ElementIndex int32 BEGIN TRY33 SELECT34 @Preproperfuellt = string_agg(convert(nvarchar(max), N '|' + x.PreProcessorString + N '|'),35 N '')36 FROM(37 SELECT38 DISTINCT PreProcessorString39 FROM dialogConfigparm c40 JOIN dialogConfigparmOption o41 ON c.UID_ConfigParm = o.UID_ConfigParm AND c.value = o.OptionValue42 WHERE43 c.isenabledResulting = 1 AND o.PreProcessorString > ' ' AND c.IsPreprocessorCondition = 1) AS x44 IF @DebugSwitch > 045 BEGIN46 print '@Preproperfuellt ' + @Preproperfuellt47 END48 SELECT49 @Query = 'select '''' as Condition union ' + string_agg(convert(nvarchar(max), CONCAT(N 'select isnull(PreProcessorCondition, '''') from '50 , t.TableName, nchar(13), nchar(10))),51 CONCAT(' union ', nchar(13), nchar(10)))52 FROM DialogColumn c53 JOIN DialogTable t54 ON c.UID_DialogTable = t.UID_DialogTable55 WHERE56 c.ColumnName = 'PreProcessorCondition'57 IF @DebugSwitch > 058 BEGIN59 print @query60 END61 INSERT INTO @Props(ContentFull)62 EXEC sp_executesql @query63 IF @DebugSwitch > 064 BEGIN65 print 'select ContentFull from @Props'66 SELECT ContentFull67 FROM @Props68 END69 DELETE @ElementBufferMulti70 INSERT INTO @ElementBufferMulti(ContentFull)71 SELECT p.ContentFull72 FROM @Props p73 WHERE74 p.ContentFull > ' '75 ORDER BY p.ContentFull DESC76 SELECT @ElementCount = @@ROWCOUNT77 SELECT @ElementIndex = @@IDENTITY - @ElementCount +178 SELECT @ElementLast = @@IDENTITY79 WHILE @ElementIndex <= @ElementLast80 BEGIN81 IF @DebugSwitch > 082 BEGIN83 print '@ElementIndex ' + str(@ElementIndex)84 END85 SELECT TOP 1 @PreProcessorCondition = bu.ContentFull86 FROM @ElementBufferMulti bu87 WHERE88 bu.ElementIndex = @ElementIndex89 EXEC @IsDeactivated = QBM_PPrePropCheckExpression @PreProcessorCondition,90 @Preproperfuellt91 SELECT @IsDeactivated = @IsDeactivated ^192 IF @DebugSwitch > 093 BEGIN94 print str(@IsDeactivated) + '#' + @PreProcessorCondition95 END96 SELECT97 @FunctionBody = @FunctionBody + '98 when ' + dbo.QBM_FSQStringAsLiteral(@PreProcessorCondition,99 0,100 0) + ' then ' + str(@IsDeactivated)101 SELECT @ElementIndex += 1102 END103 SELECT @FunctionBody = @FunctionBody + + '104 else 1105 end106 ) 107end108'109 SELECT @oldcode = NULL110 SELECT TOP 1 @OldCode = m.definition111 FROM sys.objects f112 JOIN sys.sql_modules m113 ON f.object_id = m.object_id114 WHERE115 f.name = @FunctionName116 IF @oldcode IS NULL117 BEGIN118 SELECT @oldcode = ''119 END120 SELECT121 @OldCode = replace(@OldCode,122 'create function',123 'create or alter function')124 IF dbo.QBM_FGIDBOwner() = 'CCC'125 BEGIN126 SELECT127 @FunctionBody = dbo.QBM_FSQRemoveComment_i(@FunctionBody,128 1)129 END130 EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @FunctionBody,131 @LockTimeout_ms = DEFAULT,132 @MaxWaitTimeForLock_s = DEFAULT,133 @ProcIDForJournal = DEFAULT,134 @HandleErrorSilent = 0135 IF trim(dbo.QBM_FSQRemoveComment_i(@FunctionBody, 1)) <> trim(dbo.QBM_FSQRemoveComment_i(@OldCode, 1))136 BEGIN137 IF @DebugSwitch > 0138 BEGIN139 print '#### is different'140 END141 EXEC QBM_PDBQueueInsert_Single 'QBM-K-PrepropAll',142 '',143 '',144 @GenProcID145 END146 END TRY147 BEGIN CATCH148 EXEC QBM_PSessionErrorAdd DEFAULT149 RAISERROR('',150 18,151 1)152 WITH NOWAIT153 END CATCH154 ende:155 RETURN156END
Open raw exported source
1 create procedure QBM_ZPrepropGenerateFunction (@SlotNumberDummy int , @dummy1 varchar(38) , @dummy2 varchar(38) , @dummyGenProcID varchar(382) ) as begin declare @Props QBM_YParameterList declare @Preproperfuellt nvarchar(max) declare @tablename varchar(30) declare @Query nvarchar(max) = 'select '''' as Condition'3 declare @PreProcessorCondition nvarchar(max) declare @IsDeactivated bit declare @FunctionName varchar(30) = 'QBM_FGIPrepropConditionDeactiv' declare @FunctionBody4 nvarchar(max) = '5create or alter function dbo.' + @FunctionName + ' (@PreProcessorCondition nvarchar(max)6 )7 returns bit8 with schemabinding9 as10 begin11 return( case isnull(@PreProcessorCondition, '''')12 when '''' then 0'13 declare @DebugSwitch int = 0 declare @GenProcID varchar(38) = newid() declare @OldCode nvarchar(max) declare @ElementLast int declare @ElementBufferMulti14 QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int BEGIN TRY select @Preproperfuellt = string_agg(convert(nvarchar(max), N'|' + x.PreProcessorString15 + N'|' ) , N'' ) from ( select distinct PreProcessorString from dialogConfigparm c join dialogConfigparmOption o on c.UID_ConfigParm = o.UID_ConfigParm16 and c.value = o.OptionValue where c.isenabledResulting = 1 and o.PreProcessorString > ' ' and c.IsPreprocessorCondition = 1 ) as x if @DebugSwitch > 017 begin print '@Preproperfuellt ' + @Preproperfuellt end select @Query = 'select '''' as Condition union ' + string_agg( convert(nvarchar(max), concat(18N'select isnull(PreProcessorCondition, '''') from ' , t.TableName , nchar(13) , nchar(10) ) ) , concat(' union ' , nchar(13) , nchar(10)) ) from DialogColumn19 c join DialogTable t on c.UID_DialogTable = t.UID_DialogTable where c.ColumnName = 'PreProcessorCondition' if @DebugSwitch > 0 begin print @query end 20insert into @Props(ContentFull) exec sp_executesql @query if @DebugSwitch > 0 begin print 'select ContentFull from @Props' select ContentFull from @Props21 end delete @ElementBufferMulti insert into @ElementBufferMulti (ContentFull) select p.ContentFull from @Props p where p.ContentFull > ' ' order by22 p.ContentFull desc select @ElementCount = @@ROWCOUNT select @ElementIndex = @@IDENTITY - @ElementCount +1 select @ElementLast = @@IDENTITY while @ElementIndex23 <= @ElementLast begin if @DebugSwitch > 0 begin print '@ElementIndex ' + str(@ElementIndex) end select top 1 @PreProcessorCondition = bu.ContentFull from24 @ElementBufferMulti bu where bu.ElementIndex = @ElementIndex exec @IsDeactivated = QBM_PPrePropCheckExpression @PreProcessorCondition, @Preproperfuellt25 select @IsDeactivated = @IsDeactivated ^1 if @DebugSwitch > 0 begin print str(@IsDeactivated) + '#' + @PreProcessorCondition end select @FunctionBody 26= @FunctionBody + '27 when ' + dbo.QBM_FSQStringAsLiteral(@PreProcessorCondition, 0, 0) + ' then ' + str(@IsDeactivated) select @ElementIndex += 1 28end select @FunctionBody = @FunctionBody + + '29 else 130 end31 ) 32end33' select @oldcode = null select top 1 @OldCode = m.definition from 34sys.objects f join sys.sql_modules m on f.object_id = m.object_id where f.name = @FunctionName if @oldcode is null begin select @oldcode = '' end select35 @OldCode = replace(@OldCode, 'create function', 'create or alter function') if dbo.QBM_FGIDBOwner() = 'CCC' begin select @FunctionBody = dbo.QBM_FSQRemoveComment_i36(@FunctionBody, 1) end exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @FunctionBody , @LockTimeout_ms = default , @MaxWaitTimeForLock_s = default , 37@ProcIDForJournal = default , @HandleErrorSilent = 0 if trim(dbo.QBM_FSQRemoveComment_i(@FunctionBody, 1)) <> trim(dbo.QBM_FSQRemoveComment_i(@OldCode,38 1)) begin if @DebugSwitch > 0 begin print '#### is different' end exec QBM_PDBQueueInsert_Single 'QBM-K-PrepropAll' , '', '', @GenProcID end39 END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH ende: return end 40