dbo.QBM_PMNTableInsert
Stored ProcedureSQL_STORED_PROCEDURESandbox DB
Interpretation
- Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.
- Object-layer bridge detected through QBM_PJobCreate helper usage.
Relations
- HOFireEvent -> ' , @TargetTable , '.' , @EventName , ' at line 54
- HOFireEvent -> .' , @EventName , ' at line 84
- References QBM_PJobCreate*
- References QBM_PJobCreate_HOFireEvent*
Typed Edges
- references source dbo.QBM_FCVElementToObjectKey2 source text reference
- references source dbo.QBM_FGIColumnExists source text reference
- references source dbo.QBM_FGISessionContext source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_PExecuteSQLWithRetry_LLP source text reference
- references source dbo.QBM_PJobCreate source text reference
- references source dbo.QBM_PJobCreate_HOFireEvent source text reference
- references source dbo.QBM_PJobCreate_HOFireEvent_L source text reference
- references source dbo.QBM_PSessionContextSet source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
References
- dbo.QBM_FCVElementToObjectKey2
- dbo.QBM_FGIColumnExists
- dbo.QBM_FGISessionContext
- dbo.QBM_FGISessionErrorRethrow
- dbo.QBM_PExecuteSQLWithRetry_LLP
- dbo.QBM_PJobCreate
- dbo.QBM_PJobCreate_HOFireEvent
- dbo.QBM_PJobCreate_HOFireEvent_L
- dbo.QBM_PSessionContextSet
- dbo.QBM_PSessionErrorAdd
Referenced By
- dbo.ADS_ZAccountInADSGroup
- dbo.ADS_ZADSMachineInADSGroup
- dbo.ADS_ZContactInADSGroup
- dbo.ADS_ZOrgHasADSGroup
- dbo.CPL_PComplianceCheckMakeProc_h
- dbo.LDP_ZAccountInLDAPGroup
- dbo.LDP_ZLDPMachineInLDAPGroup
- dbo.LDP_ZOrgHasLDAPGroup
- dbo.POL_ZQERPolicyFill
- dbo.QBM_PMNTableInsertOwnPK
- dbo.QER_PDynamicGroupMakeProc_hlp
- dbo.QER_ZHelperHardwareOrg
- dbo.QER_ZHelperHeadOrg
- dbo.QER_ZHelperHeadPerson
- dbo.QER_ZHelperPersonOrg
- dbo.QER_ZHelperWorkDeskOrg
- dbo.QER_ZOrgHasQERAssign
- dbo.QER_ZOrgHasQERResource
- dbo.QER_ZOrgHasQERReuse
- dbo.QER_ZOrgHasQERReuseUS
- dbo.QER_ZPersonHasQERAssign
- dbo.QER_ZPersonHasQERResource
- dbo.QER_ZPersonHasQERReuse
- dbo.QER_ZPersonHasQERReuseUS
- dbo.RMB_ZHelperHardwareOrg
- dbo.RMB_ZHelperPersonOrg
- dbo.RMB_ZHelperWorkDeskOrg
- dbo.RMS_ZESetHasEntitlement
- dbo.RMS_ZOrgHasESet
- dbo.RMS_ZPersonHasESet
- dbo.RMS_ZWorkDeskHasESet
- dbo.RPS_ZOrgHasRPSReport
- dbo.RPS_ZPersonHasRPSReport
- dbo.TSB_ZOrgHasTSBAccountDef
- dbo.TSB_ZOrgHasUNSGroupB
- dbo.TSB_ZOrgHasUNSGroupB1
- dbo.TSB_ZOrgHasUNSGroupB2
- dbo.TSB_ZOrgHasUNSGroupB3
- dbo.TSB_ZPersonHasTSBAccountDef
- dbo.TSB_ZUNSAccountBHasUNSItemB
- dbo.TSB_ZUNSAccountBInUNSGroupB
- dbo.TSB_ZUNSAccountBInUNSGroupB1
- dbo.TSB_ZUNSAccountBInUNSGroupB2
- dbo.TSB_ZUNSAccountBInUNSGroupB3
- dbo.TSB_ZUNSGroupBHasUNSItemB
Complete Source
1CREATE PROCEDURE QBM_PMNTableInsert(2 @TargetTable varchar(30),3 @ElementColumn varchar(30),4 @AssignedElementColumn varchar(30),5 @TargetIsView BIT = 0,6 @FKTableNameElement varchar(30) = '',7 @FKColumnNameElement varchar(30) = ''8)9AS10BEGIN11 DECLARE @GenProcID varchar(38)12 DECLARE @SQLCmdInsert nvarchar(max) = N ''13 DECLARE @SQLCmdFire nvarchar(max) = N ''14 DECLARE @SQLAction nvarchar(max)15 DECLARE @InsertLine nvarchar(max)16 DECLARE @SelectLine nvarchar(max)17 DECLARE @TargetTableView varchar(30)18 DECLARE @UID_DialogTableTarget varchar(38)19 DECLARE @IsAssignmentWithEvent BIT20 DECLARE @DebugSwitch int = 021 DECLARE @EventName nvarchar(64)22 DECLARE @ExistsXObjectKey BIT23 DECLARE @ExistsXOrigin BIT24 DECLARE @ExistsXIsInEffect BIT25 DECLARE @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('')26 DECLARE @XUser_R nvarchar(64) = dbo.QBM_FGISessionContext('XUser')27 DECLARE @ElementCount int28 DECLARE @ElementIndex int29 DECLARE @DifferentTables QBM_YCursorBuffer30 DECLARE @ElementCountDifferentTables int31 DECLARE @ElementIndexDifferentTables int32 DECLARE @ElementLastDifferentTables int33 DECLARE @MaxWaitTimeForMainOperation float = 8.034 SET XACT_ABORT OFF35 BEGIN TRY36 SELECT37 TOP 1 @UID_DialogTableTarget = t.UID_DialogTable,38 @IsAssignmentWithEvent = t.isAssignmentWithEvent39 FROM DialogTable t40 WITH(readpast)41 WHERE42 t.TableName = @TargetTable43 SELECT44 @ExistsXObjectKey = dbo.QBM_FGIColumnExists(@TargetTable,45 'XObjectKey')46 SELECT47 @ExistsXOrigin = dbo.QBM_FGIColumnExists(@TargetTable,48 'XOrigin')49 SELECT50 @ExistsXIsInEffect = dbo.QBM_FGIColumnExists(@TargetTable,51 'XIsInEffect')52 SELECT53 @InsertLine = CONCAT('54 insert into ',55 @TargetTable,56 ' ( ',57 @ElementColumn,58 ' , ',59 @AssignedElementColumn)60 SELECT61 @SelectLine = '62 select d.Element, d.AssignedElement '63 IF @ExistsXObjectKey = 164 BEGIN65 SELECT66 @InsertLine = CONCAT(@InsertLine,67 ', XObjectKey')68 SELECT69 @SelectLine = CONCAT(@SelectLine,70 ', @XObjectKey@')71 END72 IF @ExistsXIsInEffect = 173 BEGIN74 SELECT @EventName = 'Assign'75 SELECT76 @InsertLine = CONCAT(@InsertLine,77 ', XIsInEffect')78 SELECT79 @SelectLine = CONCAT(@SelectLine,80 ', d.XIsInEffect')81 END82 ELSE83 BEGIN84 SELECT @EventName = 'Insert'85 END86 IF @IsAssignmentWithEvent = 1 AND NOT EXISTS(87 SELECT TOP 1 188 FROM QBMEvent q89 WITH(readpast)90 JOIN JobEventGen e91 WITH(readpast)92 ON q.UID_QBMEvent = e.UID_QBMEvent93 JOIN JobChain c94 ON e.UID_JobChain = c.UID_JobChain95 WHERE96 q.UID_DialogTable = @UID_DialogTableTarget AND q.EventName = @EventName AND c.NoGenerate = 0 AND c.IsDeactivatedByPreProcessor = 0)97 BEGIN98 SELECT @IsAssignmentWithEvent = 099 END100 IF @ExistsXOrigin = 1101 BEGIN102 SELECT103 @InsertLine = CONCAT(@InsertLine,104 ', XOrigin')105 SELECT106 @SelectLine = CONCAT(@SelectLine,107 ', d.XOrigin')108 END109 IF EXISTS(110 SELECT TOP 1 1111 FROM DialogColumn c112 WITH(readpast)113 WHERE114 c.UID_DialogTable = @UID_DialogTableTarget AND c.ColumnName = 'XdateInserted')115 BEGIN116 SELECT117 @InsertLine = CONCAT(@InsertLine,118 ', XDateInserted , XDateUpdated , XUserInserted , XUserUpdated ')119 SELECT120 @SelectLine = CONCAT(@SelectLine,121 ', getutcdate() , getutcdate() , ''QBM_DBQueueProcess'' , ''QBM_DBQueueProcess'' ')122 END123 SELECT124 @SQLCmdInsert = CONCAT(@InsertLine,125 ')',126 @SelectLine,127 ' 128 from #QBMDeltaInsert d 129 where d.GenProcID = ''@GenProciD''130 and Not exists (select top 1 1131 from ',132 @TargetTable,133 ' z 134 where z.',135 @ElementColumn,136 ' = d.element137 and z.',138 @AssignedElementColumn,139 ' = d.AssignedElement140 )')141 IF @TargetIsView = 0142 BEGIN143 IF @IsAssignmentWithEvent = 1144 BEGIN145 SELECT146 @SQLCmdFire = '147 declare @EntriesToFire QBM_YParameterList 148 declare @AddonElements QBM_YParameterList 149 150 insert into @EntriesToFire(Parameter1)151 select @XObjectKey@152 from #QBMDeltaInsert d153 where d.GenProcID = ''@GenProciD''154 '155 IF @ExistsXIsInEffect = 1156 BEGIN157 SELECT158 @SQLCmdFire = CONCAT(@SQLCmdFire,159 '160 and d.XIsInEffect = 1161 ')162 END163 IF @FKTableNameElement > ' ' AND @FKColumnNameElement > ' '164 BEGIN165 SELECT166 @SQLCmdFire = CONCAT(@SQLCmdFire,167 '168 169 insert into @AddonElements(Parameter1, Parameter2)170 select distinct x.XObjectKey, @XObjectKey@171 from #QBMDeltaInsert d join '172 ,173 @FKTableNameElement,174 ' x on x.',175 @FKColumnNameElement,176 ' = d.Element177 where d.GenProcID = ''@GenProciD''178 ')179 END180 SELECT181 @SQLCmdFire = CONCAT(@SQLCmdFire,182 ' 183184 exec QBM_PJobCreate_HOFireEvent_L ''',185 @TargetTable,186 ''', @EntriesToFire, ''',187 @EventName,188 ''', ''@GenProcID''189 , @AddonElements190 , @isToFreezeOnError = 1191192 ')193 END194 SELECT195 @SQLCmdInsert = REPLACE(@SQLCmdInsert,196 '@XObjectKey@',197 CONCAT('dbo.QBM_FCVElementToObjectKey2(''', @TargetTable, ''', ''', @ElementColumn, ''', d.Element, ''',198 @AssignedElementColumn, ''', d.AssignedElement)'))199 SELECT200 @SQLCmdFire = REPLACE(@SQLCmdFire,201 '@XObjectKey@',202 CONCAT('dbo.QBM_FCVElementToObjectKey2(''', @TargetTable, ''', ''', @ElementColumn, ''', d.Element, ''',203 @AssignedElementColumn, ''', d.AssignedElement)'))204 END205 ELSE206 BEGIN207 SELECT208 @SQLCmdFire = '209 declare @EntriesToFire QBM_YParameterList 210 declare @AddonElements QBM_YParameterList 211 212 insert into @EntriesToFire(Parameter1)213 select @XObjectKey@214 from #QBMDeltaInsert d215 where d.GenProcID = ''@GenProciD''216 and d.TargetTableView = ''@TargetTableView@''217 '218 IF @ExistsXIsInEffect = 1219 BEGIN220 SELECT221 @SQLCmdFire = CONCAT(@SQLCmdFire,222 '223 and d.XIsInEffect = 1224 ')225 END226 IF @FKTableNameElement > ' ' AND @FKColumnNameElement > ' '227 BEGIN228 SELECT229 @SQLCmdFire = CONCAT(@SQLCmdFire,230 '231 insert into @AddonElements(Parameter1, Parameter2)232 select distinct x.XObjectKey, @XObjectKey@233 from #QBMDeltaInsert d join ',234 @FKTableNameElement,235 ' x on x.',236 @FKColumnNameElement,237 ' = d.Element238 where d.GenProcID = ''@GenProciD''239 ')240 END241 SELECT242 @SQLCmdFire = CONCAT(@SQLCmdFire,243 ' 244245 exec QBM_PJobCreate_HOFireEvent_L ''@TargetTableView@'', @EntriesToFire, ''',246 @EventName,247 ''', ''@GenProcID''248 , @AddonElements249 , @isToFreezeOnError = 1250251 ')252 SELECT253 @SQLCmdInsert = REPLACE(@SQLCmdInsert,254 '@XObjectKey@',255 'dbo.QBM_FCVElementToObjectKey2( d.TargetTableView , d.ElementColumnView , d.Element, d.AssignedElementColumnView, d.AssignedElement)')256 SELECT257 @SQLCmdFire = REPLACE(@SQLCmdFire,258 '@XObjectKey@',259 'dbo.QBM_FCVElementToObjectKey2( d.TargetTableView , d.ElementColumnView , d.Element, d.AssignedElementColumnView, d.AssignedElement)')260 END261 IF @DebugSwitch > 0262 BEGIN263 print '@SQLCmdInsert' +char(13) + char(10) + @SQLCmdInsert print '@SQLCmdFire' +char(13) + char(10) + @SQLCmdFire264 END265 DECLARE @GenProcIDs_CountInsert QBM_YCursorBuffer266 INSERT INTO @GenProcIDs_CountInsert(UID1)267 SELECT268 DISTINCT d.GenProcID269 FROM #QBMDeltaInsert d270 SELECT @ElementCount = @@ROWCOUNT271 SELECT @ElementIndex = 1272 WHILE @ElementIndex <= @ElementCount273 BEGIN274 SELECT TOP 1 @GenProcID = bu.UID1275 FROM @GenProcIDs_CountInsert bu276 WHERE277 bu.ElementIndex = @ElementIndex278 EXEC QBM_PSessionContextSet 'GenProcID',279 @GenProcID280 SELECT281 @SQLAction = REPLACE(@SQLCmdInsert,282 '@GenProcID',283 @GenProcID)284 IF @DebugSwitch > 0285 BEGIN286 print '@SQLAction ' + isnull(@SQLAction,287 '<keine>')288 END289 EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLAction,290 @LockTimeout_ms = DEFAULT,291 @MaxWaitTimeForLock_s = @MaxWaitTimeForMainOperation,292 @ProcIDForJournal = DEFAULT,293 @HandleErrorSilent = 0294 IF @TargetIsView = 0295 BEGIN296 IF @SQLCmdFire > ' '297 BEGIN298 SELECT299 @SQLAction = REPLACE(@SQLCmdFire,300 '@GenProcID',301 @GenProcID)302 IF @DebugSwitch > 0303 BEGIN304 print '@SQLAction ' + isnull(@SQLAction,305 '<keine>')306 END307 EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLAction,308 @LockTimeout_ms = DEFAULT,309 @MaxWaitTimeForLock_s = 4.0,310 @ProcIDForJournal = DEFAULT,311 @HandleErrorSilent = 0312 END313 END314 ELSE315 BEGIN316 DELETE @DifferentTables317 INSERT INTO @DifferentTables(UID1,318 Bit1,319 UID2)320 SELECT321 DISTINCT d.TargetTableView,322 t.isAssignmentWithEvent,323 t.UID_DialogTable324 FROM #QBMDeltaInsert d325 JOIN DialogTable t326 WITH(readpast)327 ON d.TargetTableView = t.TableName328 SELECT @ElementCountDifferentTables = @@ROWCOUNT329 SELECT @ElementIndexDifferentTables = @@IDENTITY - @ElementCount +1330 SELECT @ElementLastDifferentTables = @@IDENTITY331 WHILE @ElementIndexDifferentTables <= @ElementLastDifferentTables332 BEGIN333 SELECT334 TOP 1 @TargetTableView = bu.UID1,335 @isAssignmentWithEvent = bu.Bit1,336 @UID_DialogTableTarget = bu.UID2337 FROM @DifferentTables bu338 WHERE339 bu.ElementIndex = @ElementIndexDifferentTables340 IF @IsAssignmentWithEvent = 1 AND NOT EXISTS(341 SELECT TOP 1 1342 FROM QBMEvent q343 WITH(readpast)344 JOIN JobEventGen e345 WITH(readpast)346 ON q.UID_QBMEvent = e.UID_QBMEvent347 JOIN JobChain c348 WITH(readpast)349 ON e.UID_JobChain = c.UID_JobChain350 WHERE351 q.UID_DialogTable = @UID_DialogTableTarget AND q.EventName = @EventName AND c.NoGenerate = 0 AND c.IsDeactivatedByPreProcessor = 0)352 BEGIN353 SELECT @IsAssignmentWithEvent = 0354 END355 IF @isAssignmentWithEvent = 1356 BEGIN357 SELECT358 @SQLAction = replace(REPLACE(@SQLCmdFire, '@GenProcID', @GenProcID),359 '@TargetTableView@',360 @TargetTableView)361 IF @DebugSwitch > 0362 BEGIN363 print '@SQLAction ' + isnull(@SQLAction,364 '<keine>')365 END366 EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLAction,367 @LockTimeout_ms = DEFAULT,368 @MaxWaitTimeForLock_s = 4.0,369 @ProcIDForJournal = DEFAULT,370 @HandleErrorSilent = 0371 END372 SELECT @ElementIndexDifferentTables += 1373 END374 END375 SELECT @ElementIndex += 1376 END377 END TRY378 BEGIN CATCH379 EXEC QBM_PSessionErrorAdd DEFAULT380 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()381 RAISERROR(@Rethrow,382 18,383 1)384 WITH NOWAIT385 END CATCH386 endLabel:387 EXEC QBM_PSessionContextSet 'GenProcID',388 @GenProcID_R389 EXEC QBM_PSessionContextSet 'XUser',390 @XUser_R391 RETURN392END
Open raw exported source
1 create procedure QBM_PMNTableInsert (@TargetTable varchar(30) , @ElementColumn varchar(30) , @AssignedElementColumn varchar(30) , @TargetIsView2 bit = 0 , @FKTableNameElement varchar(30) = '' , @FKColumnNameElement varchar(30) = '' ) as begin declare @GenProcID varchar(38) declare @SQLCmdInsert3 nvarchar(max) = N'' declare @SQLCmdFire nvarchar(max) = N'' declare @SQLAction nvarchar(max) declare @InsertLine nvarchar(max) declare @SelectLine nvarchar4(max) declare @TargetTableView varchar(30) declare @UID_DialogTableTarget varchar(38) declare @IsAssignmentWithEvent bit declare @DebugSwitch int = 05 declare @EventName nvarchar(64) declare @ExistsXObjectKey bit declare @ExistsXOrigin bit declare @ExistsXIsInEffect bit declare @GenProcID_R varchar(386) = dbo.QBM_FGISessionContext('') declare @XUser_R nvarchar(64) = dbo.QBM_FGISessionContext('XUser') declare @ElementCount int declare @ElementIndex int7 declare @DifferentTables QBM_YCursorBuffer declare @ElementCountDifferentTables int declare @ElementIndexDifferentTables int declare @ElementLastDifferentTables8 int declare @MaxWaitTimeForMainOperation float = 8.0 SET XACT_ABORT OFF BEGIN TRY select top 1 @UID_DialogTableTarget = t.UID_DialogTable , @IsAssignmentWithEvent9 = t.isAssignmentWithEvent from DialogTable t with (readpast) where t.TableName = @TargetTable select @ExistsXObjectKey = dbo.QBM_FGIColumnExists(@TargetTable10, 'XObjectKey') select @ExistsXOrigin = dbo.QBM_FGIColumnExists(@TargetTable, 'XOrigin') select @ExistsXIsInEffect = dbo.QBM_FGIColumnExists(@TargetTable11, 'XIsInEffect') select @InsertLine = concat('12 insert into ' , @TargetTable , ' ( ' , @ElementColumn , ' , ' , @AssignedElementColumn ) select @SelectLine13 = '14 select d.Element, d.AssignedElement ' if @ExistsXObjectKey = 1 begin select @InsertLine = concat(@InsertLine , ', XObjectKey') select @SelectLine15 = concat(@SelectLine , ', @XObjectKey@') end if @ExistsXIsInEffect = 1 begin select @EventName = 'Assign' select @InsertLine = concat(@InsertLine , ', XIsInEffect'16) select @SelectLine = concat(@SelectLine , ', d.XIsInEffect') end else begin select @EventName = 'Insert' end if @IsAssignmentWithEvent = 1 and not exists17 (select top 1 1 from QBMEvent q with (readpast) join JobEventGen e with (readpast) on q.UID_QBMEvent = e.UID_QBMEvent join JobChain c on e.UID_JobChain18 = c.UID_JobChain where q.UID_DialogTable = @UID_DialogTableTarget and q.EventName = @EventName and c.NoGenerate = 0 and c.IsDeactivatedByPreProcessor 19= 0 ) begin select @IsAssignmentWithEvent = 0 end if @ExistsXOrigin = 1 begin select @InsertLine = concat(@InsertLine , ', XOrigin') select @SelectLine20 = concat(@SelectLine , ', d.XOrigin') end if exists(select top 1 1 from DialogColumn c with (readpast) where c.UID_DialogTable = @UID_DialogTableTarget21 and c.ColumnName = 'XdateInserted' ) begin select @InsertLine = concat(@InsertLine , ', XDateInserted , XDateUpdated , XUserInserted , XUserUpdated '22) select @SelectLine = concat(@SelectLine , ', getutcdate() , getutcdate() , ''QBM_DBQueueProcess'' , ''QBM_DBQueueProcess'' ') end select @SQLCmdInsert23 = concat(@InsertLine , ')' , @SelectLine , ' 24 from #QBMDeltaInsert d 25 where d.GenProcID = ''@GenProciD''26 and Not exists (select top 1 127 from '28 , @TargetTable , ' z 29 where z.' , @ElementColumn , ' = d.element30 and z.' , @AssignedElementColumn , ' = d.AssignedElement31 )' )32 if @TargetIsView = 0 begin if @IsAssignmentWithEvent = 1 begin select @SQLCmdFire = '33 declare @EntriesToFire QBM_YParameterList 34 declare @AddonElements QBM_YParameterList 35 36 insert into @EntriesToFire(Parameter1)37 select @XObjectKey@38 from #QBMDeltaInsert d39 where d.GenProcID = ''@GenProciD''40 '41 if @ExistsXIsInEffect = 1 begin select @SQLCmdFire = concat(@SQLCmdFire , '42 and d.XIsInEffect = 143 ' ) end if @FKTableNameElement > ' ' and @FKColumnNameElement44 > ' ' begin select @SQLCmdFire = concat(@SQLCmdFire , '45 46 insert into @AddonElements(Parameter1, Parameter2)47 select distinct x.XObjectKey, @XObjectKey@48 from #QBMDeltaInsert d join '49 , @FKTableNameElement , ' x on x.' , @FKColumnNameElement , ' = d.Element50 where d.GenProcID = ''@GenProciD''51 ' ) end select @SQLCmdFire = concat52(@SQLCmdFire , ' 5354 exec QBM_PJobCreate_HOFireEvent_L ''' , @TargetTable , ''', @EntriesToFire, ''' , @EventName , ''', ''@GenProcID''55 , @AddonElements56 , @isToFreezeOnError = 15758 '59 ) end select @SQLCmdInsert = REPLACE(@SQLCmdInsert, '@XObjectKey@', concat('dbo.QBM_FCVElementToObjectKey2(''' , @TargetTable , ''', ''' , @ElementColumn60 , ''', d.Element, ''' , @AssignedElementColumn , ''', d.AssignedElement)' ) ) select @SQLCmdFire = REPLACE(@SQLCmdFire, '@XObjectKey@', concat('dbo.QBM_FCVElementToObjectKey2('''61 , @TargetTable , ''', ''' , @ElementColumn , ''', d.Element, ''' , @AssignedElementColumn , ''', d.AssignedElement)') ) end else begin select @SQLCmdFire62 = '63 declare @EntriesToFire QBM_YParameterList 64 declare @AddonElements QBM_YParameterList 65 66 insert into @EntriesToFire(Parameter1)67 select @XObjectKey@68 from #QBMDeltaInsert d69 where d.GenProcID = ''@GenProciD''70 and d.TargetTableView = ''@TargetTableView@''71 '72 if @ExistsXIsInEffect = 1 begin select @SQLCmdFire = concat(@SQLCmdFire , '73 and d.XIsInEffect = 174 ' ) end if @FKTableNameElement > ' ' and @FKColumnNameElement75 > ' ' begin select @SQLCmdFire = concat(@SQLCmdFire , '76 insert into @AddonElements(Parameter1, Parameter2)77 select distinct x.XObjectKey, @XObjectKey@78 from #QBMDeltaInsert d join '79 , @FKTableNameElement , ' x on x.' , @FKColumnNameElement , ' = d.Element80 where d.GenProcID = ''@GenProciD''81 ' ) end select @SQLCmdFire = concat82(@SQLCmdFire , ' 8384 exec QBM_PJobCreate_HOFireEvent_L ''@TargetTableView@'', @EntriesToFire, ''' , @EventName , ''', ''@GenProcID''85 , @AddonElements86 , @isToFreezeOnError = 18788 '89 ) select @SQLCmdInsert = REPLACE(@SQLCmdInsert, '@XObjectKey@', 'dbo.QBM_FCVElementToObjectKey2( d.TargetTableView , d.ElementColumnView , d.Element, d.AssignedElementColumnView, d.AssignedElement)'90 ) select @SQLCmdFire = REPLACE(@SQLCmdFire, '@XObjectKey@', 'dbo.QBM_FCVElementToObjectKey2( d.TargetTableView , d.ElementColumnView , d.Element, d.AssignedElementColumnView, d.AssignedElement)'91 ) end if @DebugSwitch > 0 begin print '@SQLCmdInsert' +char(13) + char(10) + @SQLCmdInsert print '@SQLCmdFire' +char(13) + char(10) + @SQLCmdFire end 92declare @GenProcIDs_CountInsert QBM_YCursorBuffer insert into @GenProcIDs_CountInsert (UID1) select distinct d.GenProcID from #QBMDeltaInsert d select 93@ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @GenProcID = bu.UID1 from @GenProcIDs_CountInsert94 bu where bu.ElementIndex = @ElementIndex exec QBM_PSessionContextSet 'GenProcID', @GenProcID select @SQLAction = REPLACE(@SQLCmdInsert , '@GenProcID'95, @GenProcID) if @DebugSwitch > 0 begin print '@SQLAction ' + isnull(@SQLAction, '<keine>') end exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLAction96 , @LockTimeout_ms = default , @MaxWaitTimeForLock_s = @MaxWaitTimeForMainOperation , @ProcIDForJournal = default , @HandleErrorSilent = 0 if @TargetIsView97 = 0 begin if @SQLCmdFire > ' ' begin select @SQLAction = REPLACE(@SQLCmdFire , '@GenProcID', @GenProcID) if @DebugSwitch > 0 begin print '@SQLAction '98 + isnull(@SQLAction, '<keine>') end exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLAction , @LockTimeout_ms = default , @MaxWaitTimeForLock_s =99 4.0 , @ProcIDForJournal = default , @HandleErrorSilent = 0 end end else begin delete @DifferentTables insert into @DifferentTables (UID1, Bit1, UID2100) select distinct d.TargetTableView, t.isAssignmentWithEvent, t.UID_DialogTable from #QBMDeltaInsert d join DialogTable t with (readpast) on d.TargetTableView101 = t.TableName select @ElementCountDifferentTables = @@ROWCOUNT select @ElementIndexDifferentTables = @@IDENTITY - @ElementCount +1 select @ElementLastDifferentTables102 = @@IDENTITY while @ElementIndexDifferentTables <= @ElementLastDifferentTables begin select top 1 @TargetTableView = bu.UID1 , @isAssignmentWithEvent 103= bu.Bit1 , @UID_DialogTableTarget = bu.UID2 from @DifferentTables bu where bu.ElementIndex = @ElementIndexDifferentTables if @IsAssignmentWithEvent =104 1 and not exists (select top 1 1 from QBMEvent q with (readpast) join JobEventGen e with (readpast) on q.UID_QBMEvent = e.UID_QBMEvent join JobChain c105 with (readpast) on e.UID_JobChain = c.UID_JobChain where q.UID_DialogTable = @UID_DialogTableTarget and q.EventName = @EventName and c.NoGenerate = 0 106and c.IsDeactivatedByPreProcessor = 0 ) begin select @IsAssignmentWithEvent = 0 end if @isAssignmentWithEvent = 1 begin select @SQLAction = replace(REPLACE107(@SQLCmdFire , '@GenProcID', @GenProcID) , '@TargetTableView@', @TargetTableView) if @DebugSwitch > 0 begin print '@SQLAction ' + isnull(@SQLAction, '<keine>'108) end exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLAction , @LockTimeout_ms = default , @MaxWaitTimeForLock_s = 4.0 , @ProcIDForJournal = default109 , @HandleErrorSilent = 0 end select @ElementIndexDifferentTables += 1 end end select @ElementIndex += 1 end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd110 default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH endLabel: exec QBM_PSessionContextSet111 'GenProcID', @GenProcID_R exec QBM_PSessionContextSet 'XUser', @XUser_R return end 112