dbo.QER_PITShopProductNodeCreate_b
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
- References QBM_PJobCreate*
Typed Edges
- references source dbo.QBM_FCVBinaryToString source text reference
- references source dbo.QBM_FCVElementToObjectKey1 source text reference
- references source dbo.QBM_FCVElementToObjectKey2 source text reference
- references source dbo.QBM_FCVObjectkeyToElement source text reference
- references source dbo.QBM_FCVStringToGUID source text reference
- references source dbo.QBM_FCVStringToGUIDMAll source text reference
- references source dbo.QBM_FGIIsSimulationMode source text reference
- references source dbo.QBM_FGISessionContext source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QER_FGIBitPatternInheritInfo source text reference
- references source dbo.QBM_PFESimulationFill source text reference
- references source dbo.QBM_PJobCreate source text reference
- references source dbo.QBM_PJobCreate_HOUpdate source text reference
- references source dbo.QBM_PSessionContextSet source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
- references source dbo.QER_PITShopProductNodeCreate source text reference
References
- dbo.QBM_FCVBinaryToString
- dbo.QBM_FCVElementToObjectKey1
- dbo.QBM_FCVElementToObjectKey2
- dbo.QBM_FCVObjectkeyToElement
- dbo.QBM_FCVStringToGUID
- dbo.QBM_FCVStringToGUIDMAll
- dbo.QBM_FGIIsSimulationMode
- dbo.QBM_FGISessionContext
- dbo.QBM_FGISessionErrorRethrow
- dbo.QER_FGIBitPatternInheritInfo
- dbo.QBM_PFESimulationFill
- dbo.QBM_PJobCreate
- dbo.QBM_PJobCreate_HOUpdate
- dbo.QBM_PSessionContextSet
- dbo.QBM_PSessionErrorAdd
- dbo.QER_PITShopProductNodeCreate
Referenced By
Complete Source
1CREATE PROCEDURE QER_PITShopProductNodeCreate_b(2 @uid_orgBO varchar(38),3 @ObjectKeyElements QBM_YParameterList READONLY,4 @GenProcID varchar(38),5 @uid_OrgPR varchar(38) = NULL OUTPUT6)7AS8BEGIN9 DECLARE @IsSimulationMode BIT = dbo.QBM_FGIIsSimulationMode()10 DECLARE @LeftViewName varchar(30) = 'ITShopOrg'11 DECLARE @LeftViewPKName varchar(30) = 'UID_ITShopOrg'12 DECLARE @WhereClauseOrg nvarchar(2000)13 DECLARE @BasisObjectKey varchar(138)14 DECLARE @uid_AccProduct varchar(38)15 DECLARE @ident_orgInitial nvarchar(256) = 'ProductNode (real name coming soon)'16 DECLARE @UID_OrgRoot varchar(38) = 'QER-V-ITShopOrg'17 DECLARE @SQLCmd nvarchar(max)18 DECLARE @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('')19 DECLARE @XUser_R nvarchar(64) = dbo.QBM_FGISessionContext('XUser')20 DECLARE @DebugSwitch int = 021 DECLARE @StringQERFGIBitPatternInheritInfo_Direct nvarchar(100) = dbo.QBM_FCVBinaryToString(convert(varbinary,22 dbo.QER_FGIBitPatternInheritInfo('|Direct|', 0)),23 0)24 DECLARE @XUser nvarchar(64) = object_name(@@procid)25 DECLARE @ElementBufferTables QBM_YCursorBuffer26 DECLARE @ElementBufferFall2 QBM_YCursorBuffer27 DECLARE @ElementBufferFall4 QBM_YCursorBuffer28 DECLARE @ElementBufferJob QBM_YCursorBuffer29 DECLARE @ElementCount int30 DECLARE @ElementIndex int31 SET XACT_ABORT OFF32 BEGIN TRY33 EXEC QBM_PSessionContextSet 'GenProcID',34 @GenProcID35 EXEC QBM_PSessionContextSet 'XUser',36 @XUser drop TABLE37 IF EXISTS #Struktur38 CREATE TABLE #Struktur(39 ObjectKeyElement varchar(138) collate database_default,40 RightTableName varchar(30) collate database_default,41 RightTableGUID varchar(38) collate database_default,42 MiddleBaseName varchar(30) collate database_default,43 MiddleBaseGUID varchar(38) collate database_default,44 MiddleBaseFKRightName varchar(30) collate database_default,45 MiddleViewFKLeftName varchar(30) collate database_default,46 MiddleViewName varchar(30) collate database_default,47 MiddleViewFKRightName varchar(30) collate database_default,48 UID_ACCProduct varchar(38) collate database_default,49 RightTablePKValue varchar(38) collate database_default,50 RemoveThePRNode BIT DEFAULT 0,51 UID_OrgPR varchar(38) collate database_default,52 CreatePRNode BIT DEFAULT 0,53 UID_PWODecisionMethod varchar(38) collate database_default,54 primary key(ObjectKeyElement),55 index #Struktur1(RightTableName)56 )57 INSERT INTO #Struktur(ObjectKeyElement,58 RightTableName,59 RightTableGUID,60 MiddleBaseName,61 MiddleBaseGUID,62 MiddleBaseFKRightName,63 MiddleViewFKLeftName,64 MiddleViewName,65 MiddleViewFKRightName,66 RightTablePKValue67 )68 SELECT el.Parameter169 AS70 ObjectKeyElement,71 tr.TableName AS RightTableName,72 tr.UID_DialogTable AS RightTableGUID,73 mb.TableName AS MiddleBaseName,74 mb.UID_DialogTable AS MiddleBaseGUID,75 CASE76 WHEN mb.PKName1 = 'UID_Org' THEN77 mb.PKName278 ELSE mb.PKName179 END AS MiddleBaseFKRightName,80 mvfkl.Columnname AS MiddleViewFKLeftName,81 mv.TableName AS MiddleViewName,82 mvfkr.ColumnName AS MiddleViewFKRightName,83 dbo.QBM_FCVObjectkeyToElement('Columnvalue1',84 el.Parameter1) AS RightTablePKValue85 FROM @ObjectKeyElements el86 JOIN DialogTable tr87 WITH(readpast)88 ON el.Parameter1 LIKE CONCAT('<Key><T>',89 tr.TableName,90 '</T>%')91 JOIN BaseTreeAssign ba92 ON ba.UID_DialogTableElement = tr.UID_DialogTable AND ba.IsITShopEnabled = 193 JOIN DialogTable mb94 WITH(readpast)95 ON ba.UID_DialogTableMN = mb.UID_DialogTable96 JOIN DialogColumn mbfkl97 WITH(readpast)98 ON mbfkl.UID_DialogTable = mb.UID_DialogTable AND mbfkl.ColumnName = 'uid_org'99 JOIN DialogTable mv100 WITH(readpast)101 ON mv.UID_DialogTableBase = mb.UID_DialogTable102 JOIN QBM_VQBMRelation viewleft103 ON viewleft.UID_DialogTableChild = mv.UID_DialogTable AND viewleft.UID_DialogTableParent = 'QER-T-ITShopOrg'104 JOIN DialogColumn mvfkl105 WITH(readpast)106 ON mvfkl.UID_DialogTable = mv.UID_DialogTable AND mbfkl.UID_DialogColumn = mvfkl.UID_BaseColumn107 JOIN QBM_VQBMRelation viewright108 ON viewright.UID_DialogTableChild = mv.UID_DialogTable AND viewright.UID_DialogTableParent = tr.UID_DialogTable109 JOIN DialogColumn mvfkr110 WITH(readpast)111 ON mv.UID_DialogTable = mvfkr.UID_DialogTable AND mvfkr.IsPKMember = 1 AND mvfkr.UID_DialogColumn <> mvfkl.UID_DialogColumn112 INSERT INTO @ElementBufferTables(UID1,113 UID2,114 UID3)115 SELECT116 DISTINCT s.RightTableName,117 s.MiddleBaseName,118 MiddleBaseFKRightName119 FROM #Struktur s120 SELECT @ElementCount = @@ROWCOUNT121 SELECT @ElementIndex = 1122 WHILE @ElementIndex <= @ElementCount123 BEGIN124 SELECT125 TOP 1 @SQLCmd = CONCAT('update #Struktur 126 set UID_ACCProduct = x.UID_ACCProduct127 from #Struktur s join ',128 bu.uid1,129 ' x on s.ObjectKeyElement = x.XObjectKey130 and s.RightTableName = ''',131 bu.UID1,132 ''' 133 ',134 '135 update #Struktur136 set RemoveThePRNode = sign(len(ISNULL(c.XObjectKey, ''''))) ^ 1137 from #Struktur s join BaseTree bo on s.RightTableName = '''138 ,139 bu.UID1,140 ''' 141 and bo.UID_Org = ''',142 @uid_orgBO,143 '''144 and bo.ITShopInfo = ''BO''145 left outer join ',146 bu.UID2,147 ' c on bo.UID_Org = c.UID_Org148 and c.',149 bu.UID3,150 ' = s.RightTablePKValue151 ',152 '153 update #struktur 154 set UID_OrgPR = pr.uid_org 155 from #Struktur s join BaseTree bo on s.RightTableName = ''',156 bu.UID1,157 ''' 158 and bo.UID_Org = ''',159 @uid_orgBO,160 '''161 and bo.ITShopInfo = ''BO''162 join BaseTree pr on pr.UID_ParentOrg = bo.UID_Org163 join ',164 bu.UID2,165 ' c on pr.UID_Org = c.UID_Org166 and c.',167 bu.UID3,168 ' = s.RightTablePKValue169 ')170 FROM @ElementBufferTables bu171 WHERE172 bu.ElementIndex = @ElementIndex173 EXEC sp_executesql @SQLCmd174 SELECT @ElementIndex += 1175 END176 UPDATE #Struktur177 SET CreatePRNode = 1,178 UID_OrgPR = NEWID()179 WHERE180 RemoveThePRNode = 0 AND UID_OrgPR IS NULL181 UPDATE #Struktur182 SET UID_PWODecisionMethod = a.UID_PWODecisionMethod183 FROM #Struktur s184 JOIN AccProduct a185 ON a.UID_AccProduct = s.UID_ACCProduct186 WHERE187 s.UID_PWODecisionMethod IS NULL AND a.UID_PWODecisionMethod > ' ' AND s.CreatePRNode = 1188 UPDATE #Struktur189 SET UID_PWODecisionMethod = g.UID_PWODecisionMethod190 FROM #Struktur s191 JOIN AccProduct a192 ON a.UID_AccProduct = s.UID_ACCProduct193 JOIN AccProductGroup g194 ON a.UID_AccProductGroup = g.UID_AccProductGroup195 WHERE196 s.UID_PWODecisionMethod IS NULL AND g.UID_PWODecisionMethod > ' ' AND s.CreatePRNode = 1197 UPDATE #Struktur198 SET UID_PWODecisionMethod = h.UID_PWODecisionMethod199 FROM #Struktur s200 JOIN PWOHelperBoardMethod h201 ON s.UID_PWODecisionMethod IS NULL AND h.UID_OrgBO = @uid_orgBO202 WHERE203 s.UID_PWODecisionMethod IS NULL AND s.CreatePRNode = 1204 INSERT INTO @ElementBufferFall2(UID1,205 UID3)206 SELECT207 DISTINCT s.MiddleBaseName,208 MiddleBaseFKRightName209 FROM #struktur s210 WHERE211 s.RemoveThePRNode = 1 AND s.CreatePRNode = 0 AND s.UID_OrgPR > ' '212 SELECT @ElementCount = @@ROWCOUNT213 SELECT @ElementIndex = 1214 WHILE @ElementIndex <= @ElementCount215 BEGIN216 SELECT217 TOP 1 @SQLCmd = CONCAT('218 UPDATE ',219 bu.UID1,220 ' 221 set XOrigin = 0222 from #Struktur s join ',223 bu.UID1,224 ' x on s.RightTablePKValue = x.',225 bu.UID3,226 '227 and s.middleBaseName = ''',228 bu.UID1,229 ''' 230 and s.uid_OrgPR = x.UID_Org231 where s.RemoveThePRNode = 1232 and s.CreatePRNode = 0233 and s.UID_OrgPR > '' ''234 235 delete '236 ,237 bu.UID1,238 '239 from #Struktur s join ',240 bu.UID1,241 ' x on s.RightTablePKValue = x.',242 bu.UID3,243 '244 and s.middleBaseName = ''',245 bu.UID1,246 ''' 247 and s.uid_OrgPR = x.UID_Org248 where s.RemoveThePRNode = 1249 and s.CreatePRNode = 0250 and s.UID_OrgPR > '' ''251252 delete BaseTree253 from #struktur s join basetree x on s.middleBaseName = '''254 ,255 bu.UID1,256 ''' 257 and s.uid_OrgPR = x.UID_Org258 where s.RemoveThePRNode = 1259 and s.CreatePRNode = 0260 and s.UID_OrgPR > '' ''261 '262 )263 FROM @ElementBufferFall2 bu264 WHERE265 bu.ElementIndex = @ElementIndex266 EXEC sp_executesql @SQLCmd267 SELECT @ElementIndex += 1268 END269 INSERT INTO BaseTree(UID_Org,270 UID_ParentOrg,271 Ident_Org,272 IsCutNode,273 Description,274 uid_OrgRoot,275 XDateInserted,276 XDateUpdated,277 XUserInserted,278 XUserUpdated,279 InternalName,280 FullPath,281 Commentary,282 ITShopInfo,283 XObjectKey,284 IsInvalidForDynamicGroup,285 UID_PWODecisionMethod)286 SELECT287 s.UID_OrgPR,288 @uid_orgBO,289 @Ident_OrgInitial,290 1,291 NULL,292 @UID_OrgRoot,293 GetUTCDate(),294 GetUTCDate(),295 'QER_PITShopProductNodeCreate',296 'QER_PITShopProductNodeCreate',297 NULL,298 NULL,299 NULL,300 'PR',301 dbo.QBM_FCVElementToObjectKey1(@LeftViewName,302 @LeftViewPKName,303 s.UID_OrgPR),304 1,305 s.UID_PWODecisionMethod306 FROM #Struktur s307 WHERE308 s.RemoveThePRNode = 0 AND s.CreatePRNode = 1309 INSERT INTO @ElementBufferFall4(UID1,310 UID2,311 UID3,312 UID4,313 UID5)314 SELECT315 DISTINCT s.MiddleBaseName,316 s.MiddleBaseFKRightName,317 s.MiddleViewName,318 s.MiddleViewFKLeftName,319 s.MiddleViewFKRightName320 FROM #Struktur s321 WHERE322 s.CreatePRNode = 1 AND s.RemoveThePRNode = 0323 SELECT @ElementCount = @@ROWCOUNT324 SELECT @ElementIndex = 1325 WHILE @ElementIndex <= @ElementCount326 BEGIN327 SELECT328 TOP 1 @SQLCmd = CONCAT('insert into ',329 bu.UID1,330 ' (UID_Org, ',331 bu.UID2,332 ' , XDateInserted , XDateUpdated , XUserInserted , XUserUpdated333 , XObjectKey334 , XOrigin, XIsInEffect335 )336 select s.uid_OrgPR , s.RightTablePKValue , GetUTCDate(), GetUTCDate(), ''QER_PITShopProductNodeCreate'', ''QER_PITShopProductNodeCreate'' 337 , dbo.QBM_FCVElementToObjectKey2('''338 ,339 bu.UID3,340 ''', ''',341 bu.UID4,342 ''', s.uid_OrgPR , ''',343 bu.UID5,344 ''', s.RightTablePKValue)345 , 1, 1346 from #struktur s347 where s.MiddleBaseName = ''',348 bu.UID1,349 '''350 and s.CreatePRNode = 1351 and s.RemoveThePRNode = 0352 -- eigentlich überflüssig aber Pferd und Apotheke353 and not exists ( select top 1 1 354 from '355 ,356 bu.UID1,357 ' e358 where e.UID_Org = s.uid_OrgPR359 and e.',360 bu.UID2,361 ' = s.RightTablePKValue362 )363 ',364 ' 365 insert into BaseTreeHasObject (UID_BaseTreeHasObject, UID_Org, ObjectKey366 , InheritInfo, XObjectKey367 )368 -- 35301 die Bildung des Wertes muß exakt so sein wie in QER_PBasetreeHsObject_PostProc369 select dbo.QBM_FCVStringToGUIDMAll(null, s.UID_OrgPR, s.ObjectKeyElement) , s.UID_OrgPR , s.ObjectKeyElement 370 , '371 ,372 @StringQERFGIBitPatternInheritInfo_Direct,373 ', dbo.QBM_FCVElementToObjectKey1(''BaseTreeHasObject'', ''UID_BaseTreeHasObject'', dbo.QBM_FCVStringToGUIDMAll(null, s.UID_OrgPR, s.ObjectKeyElement))374 from #struktur s375 where s.MiddleBaseName = '''376 ,377 bu.UID1,378 '''379 and s.CreatePRNode = 1380 and s.RemoveThePRNode = 0381 -- eigentlich überflüssig aber Pferd und Apotheke382 and Not exists (select top 1 1383 from BaseTreeHasObject bho384 where bho.UID_Org = s.UID_OrgPR385 and bho.ObjectKey = s.ObjectKeyElement386 )387 '388 )389 FROM @ElementBufferFall4 bu390 WHERE391 bu.ElementIndex = @ElementIndex392 EXEC sp_executesql @SQLCmd393 IF @IsSimulationMode = 1394 BEGIN395 SELECT396 @SQLCmd = CONCAT('397 declare @SimulationModeBuffer QBM_YTriggerOperation398399 insert into @SimulationModeBuffer (operation, BaseObjectType, ColumnName, Objectkey, OldValue) 400 select ''I'', ''ITShopOrg'', '''', 401 dbo.QBM_FCVElementToObjectKey1(''ITShopOrg'',402 ''uid_ITShopOrg'', s.uid_OrgPR) , ''''403 from #struktur s404 where s.MiddleBaseName = '''405 ,406 bu.UID1,407 '''408 and s.CreatePRNode = 1409 and s.RemoveThePRNode = 0410411 insert into @SimulationModeBuffer (operation, BaseObjectType, ColumnName, Objectkey, OldValue) 412 select ''I'', '''413 ,414 bu.UID3,415 ''', '''', 416 dbo.QBM_FCVElementToObjectKey2(''',417 bu.UID3,418 ''',419 ''uid_ITShopOrg'', s.uid_OrgPR, ''',420 bu.UID2,421 ''' , s.RightTablePKValue) , ''''422423 from #struktur s424 where s.MiddleBaseName = ''',425 bu.UID1,426 '''427 and s.CreatePRNode = 1428 and s.RemoveThePRNode = 0429430 exec QBM_PFESimulationFill @SimulationModeBuffer431432 ')433 FROM @ElementBufferFall4 bu434 WHERE435 bu.ElementIndex = @ElementIndex436 EXEC sp_executesql @SQLCmd437 END438 SELECT @ElementIndex += 1439 END440 INSERT INTO @ElementBufferJob(UID1,441 UID2)442 SELECT443 DISTINCT s.UID_OrgPR,444 s.UID_ACCProduct445 FROM #Struktur s446 WHERE447 s.CreatePRNode = 1 AND s.RemoveThePRNode = 0 AND EXISTS(448 SELECT TOP 1 1449 FROM dialogcolumn450 WITH(readpast)451 WHERE452 UID_DialogTable = 'QER-T-ITShopOrg' AND ColumnName = 'uid_ACCProduct' AND IsDeactivatedByPreProcessor = 0)453 SELECT @ElementCount = @@ROWCOUNT454 SELECT @ElementIndex = 1455 WHILE @ElementIndex <= @ElementCount456 BEGIN457 SELECT458 TOP 1 @WhereClauseOrg = CONCAT('UID_ITShopOrg = ''',459 bu.UID1,460 ''''),461 @BasisObjectKey = dbo.QBM_FCVElementToObjectKey1('ITShopOrg',462 'UID_ITShopOrg',463 bu.UID1),464 @uid_AccProduct = bu.UID2465 FROM @ElementBufferJob bu466 WHERE467 bu.ElementIndex = @ElementIndex468 EXEC QBM_PJobCreate_HOUpdate 'ITShopOrg',469 @whereclauseOrg,470 @GenProcID,471 @ObjectKeysAffected = DEFAULT,472 @p1 = 'uid_ACCProduct',473 @v1 = @uid_accproduct,474 @BasisObjectKey = @BasisObjectKey,475 @isToFreezeOnError = 1,476 @Retries = 2477 SELECT478 @SQLCmd = CONCAT('update ITShopOrg set UID_AccProduct = ''',479 @uid_ACCProduct,480 ''' where ',481 @WhereClauseOrg)482 EXEC sp_executesql @SQLCmd483 SELECT @ElementIndex += 1484 END485END TRY486BEGIN CATCH487 EXEC QBM_PSessionErrorAdd DEFAULT488 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()489 RAISERROR(@Rethrow,490 18,491 1)492 WITH NOWAIT493END CATCH494ende:495EXEC QBM_PSessionContextSet 'GenProcID',496 @GenProcID_R497EXEC QBM_PSessionContextSet 'XUser',498 @XUser_R499SELECT TOP 1 @uid_OrgPR = s.UID_OrgPR500FROM #Struktur s501RETURN502END
Open raw exported source
1 create procedure QER_PITShopProductNodeCreate_b( @uid_orgBO varchar(38) , @ObjectKeyElements QBM_YParameterList readonly , @GenProcID varchar2(38) , @uid_OrgPR varchar(38) = null output ) AS begin declare @IsSimulationMode bit = dbo.QBM_FGIIsSimulationMode() declare @LeftViewName varchar(30)3 = 'ITShopOrg' declare @LeftViewPKName varchar(30) = 'UID_ITShopOrg' declare @WhereClauseOrg nvarchar(2000) declare @BasisObjectKey varchar(138) declare4 @uid_AccProduct varchar(38) declare @ident_orgInitial nvarchar(256) = 'ProductNode (real name coming soon)' declare @UID_OrgRoot varchar(38) = 'QER-V-ITShopOrg'5 declare @SQLCmd nvarchar(max) declare @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('') declare @XUser_R nvarchar(64) = dbo.QBM_FGISessionContext6('XUser') declare @DebugSwitch int = 0 declare @StringQERFGIBitPatternInheritInfo_Direct nvarchar(100) = dbo.QBM_FCVBinaryToString(convert(varbinary, dbo.QER_FGIBitPatternInheritInfo7('|Direct|', 0)), 0) declare @XUser nvarchar(64) = object_name(@@procid) declare @ElementBufferTables QBM_YCursorBuffer declare @ElementBufferFall2 QBM_YCursorBuffer8 declare @ElementBufferFall4 QBM_YCursorBuffer declare @ElementBufferJob QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int SET XACT_ABORT9 OFF BEGIN TRY exec QBM_PSessionContextSet 'GenProcID', @GenProcID exec QBM_PSessionContextSet 'XUser', @XUser drop table if exists #Struktur CREATE 10TABLE #Struktur (ObjectKeyElement varchar(138) collate database_default , RightTableName varchar(30) collate database_default , RightTableGUID varchar(3811) collate database_default , MiddleBaseName varchar(30) collate database_default , MiddleBaseGUID varchar(38) collate database_default , MiddleBaseFKRightName12 varchar(30) collate database_default , MiddleViewFKLeftName varchar(30) collate database_default , MiddleViewName varchar(30) collate database_default13 , MiddleViewFKRightName varchar(30) collate database_default , UID_ACCProduct varchar(38) collate database_default , RightTablePKValue varchar(38) collate14 database_default , RemoveThePRNode bit default 0 , UID_OrgPR varchar(38) collate database_default , CreatePRNode bit default 0 , UID_PWODecisionMethod15 varchar(38) collate database_default , primary key (ObjectKeyElement) , index #Struktur1 (RightTableName) ) insert into #Struktur( ObjectKeyElement , 16RightTableName , RightTableGUID , MiddleBaseName , MiddleBaseGUID , MiddleBaseFKRightName , MiddleViewFKLeftName , MiddleViewName , MiddleViewFKRightName17 , RightTablePKValue ) select el.Parameter1 as ObjectKeyElement , tr.TableName as RightTableName , tr.UID_DialogTable as RightTableGUID , mb.TableName 18as MiddleBaseName , mb.UID_DialogTable as MiddleBaseGUID , case when mb.PKName1 = 'UID_Org' then mb.PKName2 else mb.PKName1 end as MiddleBaseFKRightName19 , mvfkl.Columnname as MiddleViewFKLeftName , mv.TableName as MiddleViewName , mvfkr.ColumnName as MiddleViewFKRightName , dbo.QBM_FCVObjectkeyToElement20('Columnvalue1', el.Parameter1 ) as RightTablePKValue from @ObjectKeyElements el join DialogTable tr with (readpast) on el.Parameter1 like concat('<Key><T>'21 , tr.TableName , '</T>%') join BaseTreeAssign ba on ba.UID_DialogTableElement = tr.UID_DialogTable and ba.IsITShopEnabled = 1 join DialogTable mb with22 (readpast) on ba.UID_DialogTableMN = mb.UID_DialogTable join DialogColumn mbfkl with (readpast) on mbfkl.UID_DialogTable = mb.UID_DialogTable and mbfkl.ColumnName23 = 'uid_org' join DialogTable mv with (readpast) on mv.UID_DialogTableBase = mb.UID_DialogTable join QBM_VQBMRelation viewleft on viewleft.UID_DialogTableChild24 = mv.UID_DialogTable and viewleft.UID_DialogTableParent = 'QER-T-ITShopOrg' join DialogColumn mvfkl with (readpast) on mvfkl.UID_DialogTable = mv.UID_DialogTable25 and mbfkl.UID_DialogColumn = mvfkl.UID_BaseColumn join QBM_VQBMRelation viewright on viewright.UID_DialogTableChild = mv.UID_DialogTable and viewright.UID_DialogTableParent26 = tr.UID_DialogTable join DialogColumn mvfkr with (readpast) on mv.UID_DialogTable = mvfkr.UID_DialogTable and mvfkr.IsPKMember = 1 and mvfkr.UID_DialogColumn27 <> mvfkl.UID_DialogColumn insert into @ElementBufferTables (UID1, UID2, UID3) select distinct s.RightTableName, s.MiddleBaseName, MiddleBaseFKRightName28 from #Struktur s select @ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @SQLCmd = concat('update #Struktur 29 set UID_ACCProduct = x.UID_ACCProduct30 from #Struktur s join '31, bu.uid1 , ' x on s.ObjectKeyElement = x.XObjectKey32 and s.RightTableName = ''', bu.UID1 , ''' 33 ', '34 update #Struktur35 set RemoveThePRNode = sign(len(ISNULL(c.XObjectKey, ''''))) ^ 136 from #Struktur s join BaseTree bo on s.RightTableName = '''37, bu.UID1 , ''' 38 and bo.UID_Org = ''' , @uid_orgBO , '''39 and bo.ITShopInfo = ''BO''40 left outer join '41 , bu.UID2 , ' c on bo.UID_Org = c.UID_Org42 and c.' , bu.UID3 , ' = s.RightTablePKValue43 ' , '44 update #struktur 45 set UID_OrgPR = pr.uid_org 46 from #Struktur s join BaseTree bo on s.RightTableName = '''47, bu.UID1 , ''' 48 and bo.UID_Org = ''' , @uid_orgBO , '''49 and bo.ITShopInfo = ''BO''50 join BaseTree pr on pr.UID_ParentOrg = bo.UID_Org51 join '52 , bu.UID2 , ' c on pr.UID_Org = c.UID_Org53 and c.' , bu.UID3 , ' = s.RightTablePKValue54 ' ) from @ElementBufferTables bu where55 bu.ElementIndex = @ElementIndex exec sp_executesql @SQLCmd select @ElementIndex += 1 end update #Struktur set CreatePRNode = 1 , UID_OrgPR = NEWID56() where RemoveThePRNode = 0 and UID_OrgPR is null update #Struktur set UID_PWODecisionMethod = a.UID_PWODecisionMethod from #Struktur s join AccProduct57 a on a.UID_AccProduct = s.UID_ACCProduct where s.UID_PWODecisionMethod is null and a.UID_PWODecisionMethod > ' ' and s.CreatePRNode = 1 update #Struktur58 set UID_PWODecisionMethod = g.UID_PWODecisionMethod from #Struktur s join AccProduct a on a.UID_AccProduct = s.UID_ACCProduct join AccProductGroup g on59 a.UID_AccProductGroup = g.UID_AccProductGroup where s.UID_PWODecisionMethod is null and g.UID_PWODecisionMethod > ' ' and s.CreatePRNode = 1 update #Struktur60 set UID_PWODecisionMethod = h.UID_PWODecisionMethod from #Struktur s join PWOHelperBoardMethod h on s.UID_PWODecisionMethod is null and h.UID_OrgBO = 61@uid_orgBO where s.UID_PWODecisionMethod is null and s.CreatePRNode = 1 insert into @ElementBufferFall2 (UID1, UID3) select distinct s.MiddleBaseName62, MiddleBaseFKRightName from #struktur s where s.RemoveThePRNode = 1 and s.CreatePRNode = 0 and s.UID_OrgPR > ' ' select @ElementCount = @@ROWCOUNT select63 @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @SQLCmd = concat('64 UPDATE ' , bu.UID1 , ' 65 set XOrigin = 066 from #Struktur s join '67, bu.UID1 , ' x on s.RightTablePKValue = x.', bu.UID3 , '68 and s.middleBaseName = ''', bu.UID1 , ''' 69 and s.uid_OrgPR = x.UID_Org70 where s.RemoveThePRNode = 171 and s.CreatePRNode = 072 and s.UID_OrgPR > '' ''73 74 delete '75 , bu.UID1 ,'76 from #Struktur s join ', bu.UID1 , ' x on s.RightTablePKValue = x.', bu.UID3 , '77 and s.middleBaseName = '''78, bu.UID1 , ''' 79 and s.uid_OrgPR = x.UID_Org80 where s.RemoveThePRNode = 181 and s.CreatePRNode = 082 and s.UID_OrgPR > '' ''8384 delete BaseTree85 from #struktur s join basetree x on s.middleBaseName = '''86, bu.UID1 , ''' 87 and s.uid_OrgPR = x.UID_Org88 where s.RemoveThePRNode = 189 and s.CreatePRNode = 090 and s.UID_OrgPR > '' ''91 '92 ) from @ElementBufferFall2 bu where bu.ElementIndex = @ElementIndex exec sp_executesql @SQLCmd select @ElementIndex += 1 end insert into93 BaseTree( UID_Org, UID_ParentOrg, Ident_Org , IsCutNode, Description , uid_OrgRoot , XDateInserted , XDateUpdated , XUserInserted , XUserUpdated, InternalName94 , FullPath ,Commentary , ITShopInfo , XObjectKey , IsInvalidForDynamicGroup , UID_PWODecisionMethod ) select s.UID_OrgPR, @uid_orgBO, @Ident_OrgInitial95, 1, null, @UID_OrgRoot, GetUTCDate(), GetUTCDate(), 'QER_PITShopProductNodeCreate', 'QER_PITShopProductNodeCreate', null, null, null , 'PR', dbo.QBM_FCVElementToObjectKey196(@LeftViewName, @LeftViewPKName, s.UID_OrgPR) , 1 , s.UID_PWODecisionMethod from #Struktur s where s.RemoveThePRNode = 0 and s.CreatePRNode = 1 97 insert into @ElementBufferFall4(UID1, UID2, UID3, UID4, UID5) select distinct s.MiddleBaseName, s.MiddleBaseFKRightName, s.MiddleViewName, s.MiddleViewFKLeftName98, s.MiddleViewFKRightName from #Struktur s where s.CreatePRNode = 1 and s.RemoveThePRNode = 0 select @ElementCount = @@ROWCOUNT select @ElementIndex = 991 while @ElementIndex <= @ElementCount begin select top 1 @SQLCmd = concat( 'insert into ' , bu.UID1 , ' (UID_Org, ' , bu.UID2 , ' , XDateInserted , XDateUpdated , XUserInserted , XUserUpdated100 , XObjectKey101 , XOrigin, XIsInEffect102 )103 select s.uid_OrgPR , s.RightTablePKValue , GetUTCDate(), GetUTCDate(), ''QER_PITShopProductNodeCreate'', ''QER_PITShopProductNodeCreate'' 104 , dbo.QBM_FCVElementToObjectKey2('''105, bu.UID3 , ''', ''', bu.UID4 , ''', s.uid_OrgPR , ''', bu.UID5 , ''', s.RightTablePKValue)106 , 1, 1107 from #struktur s108 where s.MiddleBaseName = '''109 , bu.UID1 , '''110 and s.CreatePRNode = 1111 and s.RemoveThePRNode = 0112 -- eigentlich überflüssig aber Pferd und Apotheke113 and not exists ( select top 1 1 114 from '115 , bu.UID1 , ' e116 where e.UID_Org = s.uid_OrgPR117 and e.' , bu.UID2 , ' = s.RightTablePKValue118 )119 ', ' 120 insert into BaseTreeHasObject (UID_BaseTreeHasObject, UID_Org, ObjectKey121 , InheritInfo, XObjectKey122 )123 -- 35301 die Bildung des Wertes muß exakt so sein wie in QER_PBasetreeHsObject_PostProc124 select dbo.QBM_FCVStringToGUIDMAll(null, s.UID_OrgPR, s.ObjectKeyElement) , s.UID_OrgPR , s.ObjectKeyElement 125 , '126 , @StringQERFGIBitPatternInheritInfo_Direct , ', dbo.QBM_FCVElementToObjectKey1(''BaseTreeHasObject'', ''UID_BaseTreeHasObject'', dbo.QBM_FCVStringToGUIDMAll(null, s.UID_OrgPR, s.ObjectKeyElement))127 from #struktur s128 where s.MiddleBaseName = '''129 , bu.UID1 , '''130 and s.CreatePRNode = 1131 and s.RemoveThePRNode = 0132 -- eigentlich überflüssig aber Pferd und Apotheke133 and Not exists (select top 1 1134 from BaseTreeHasObject bho135 where bho.UID_Org = s.UID_OrgPR136 and bho.ObjectKey = s.ObjectKeyElement137 )138 '139 ) from @ElementBufferFall4 bu where bu.ElementIndex = @ElementIndex exec sp_executesql @SQLCmd if @IsSimulationMode = 1 begin select @SQLCmd = concat140('141 declare @SimulationModeBuffer QBM_YTriggerOperation142143 insert into @SimulationModeBuffer (operation, BaseObjectType, ColumnName, Objectkey, OldValue) 144 select ''I'', ''ITShopOrg'', '''', 145 dbo.QBM_FCVElementToObjectKey1(''ITShopOrg'',146 ''uid_ITShopOrg'', s.uid_OrgPR) , ''''147 from #struktur s148 where s.MiddleBaseName = '''149 , bu.UID1 , '''150 and s.CreatePRNode = 1151 and s.RemoveThePRNode = 0152153 insert into @SimulationModeBuffer (operation, BaseObjectType, ColumnName, Objectkey, OldValue) 154 select ''I'', '''155, bu.UID3 , ''', '''', 156 dbo.QBM_FCVElementToObjectKey2(''', bu.UID3 , ''',157 ''uid_ITShopOrg'', s.uid_OrgPR, ''' , bu.UID2 , 158''' , s.RightTablePKValue) , ''''159160 from #struktur s161 where s.MiddleBaseName = ''' , bu.UID1 , '''162 and s.CreatePRNode = 1163 and s.RemoveThePRNode = 0164165 exec QBM_PFESimulationFill @SimulationModeBuffer166167 '168 ) from @ElementBufferFall4 bu where bu.ElementIndex = @ElementIndex exec sp_executesql @SQLCmd end select @ElementIndex += 1 end insert into @ElementBufferJob169(UID1, UID2) select distinct s.UID_OrgPR, s.UID_ACCProduct from #Struktur s where s.CreatePRNode = 1 and s.RemoveThePRNode = 0 and exists (select top 1701 1 from dialogcolumn with (readpast) where UID_DialogTable = 'QER-T-ITShopOrg' and ColumnName = 'uid_ACCProduct' and IsDeactivatedByPreProcessor = 0 )171 select @ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @WhereClauseOrg = concat('UID_ITShopOrg = '''172 , bu.UID1 , '''') , @BasisObjectKey = dbo.QBM_FCVElementToObjectKey1('ITShopOrg', 'UID_ITShopOrg', bu.UID1) , @uid_AccProduct = bu.UID2 from @ElementBufferJob173 bu where bu.ElementIndex = @ElementIndex exec QBM_PJobCreate_HOUpdate 'ITShopOrg', @whereclauseOrg, @GenProcID , @ObjectKeysAffected = default , @p1 =174 'uid_ACCProduct' , @v1 = @uid_accproduct , @BasisObjectKey = @BasisObjectKey , @isToFreezeOnError = 1 , @Retries = 2 select @SQLCmd = concat('update ITShopOrg set UID_AccProduct = '''175, @uid_ACCProduct, ''' where ', @WhereClauseOrg) exec sp_executesql @SQLCmd select @ElementIndex += 1 end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd176 default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH ende: exec QBM_PSessionContextSet177 'GenProcID', @GenProcID_R exec QBM_PSessionContextSet 'XUser', @XUser_R select top 1 @uid_OrgPR = s.UID_OrgPR from #Struktur s return end 178