Back to OIM Explorer

dbo.QER_PITShopProductNodeMove

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 10.016 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_FCVBinaryToString source text reference
  • references source dbo.QBM_FCVDatetimeToString 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_FGIPrimaryKeyName source text reference
  • references source dbo.QBM_FGIPrimaryKeyName_F source text reference
  • references source dbo.QBM_FGISessionContext source text reference
  • references source dbo.QBM_FGISessionErrorRethrow source text reference
  • references source dbo.QBM_FGITableName source text reference
  • references source dbo.QER_FGIBitPatternInheritInfo source text reference
  • references source dbo.QBM_PExecuteSQLWithRetry_LLP source text reference
  • references source dbo.QBM_PJournal source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference
  • references source dbo.QER_PITShopOrderMove source text reference
  • references source dbo.QER_PITShopOrderMove_bulk source text reference
  • references source dbo.QER_PITShopProductNodeCreate source text reference

Complete Source

SQL376 lines
1CREATE PROCEDURE QER_PITShopProductNodeMove(2  @uid_OrgPR_Old varchar(38),3  @uid_orgBO_new varchar(38)4)5AS6BEGIN7  DECLARE @uid_OrgPR_New varchar(38)8  DECLARE @uid_OrgSH_New varchar(38)9  DECLARE @uid_OrgCU_New varchar(38)10  DECLARE @uid_orgBO_Old varchar(38)11  DECLARE @uid_orgSH_Old varchar(38)12  DECLARE @uid_orgCU_Old varchar(38)13  DECLARE @Ident_OrgBO_New nvarchar(256)14  DECLARE @Ident_OrgSH_New nvarchar(256)15  DECLARE @ObjectKeyElement varchar(138)16  DECLARE @UID_AccProduct varchar(38)17  DECLARE @SQLCmdDelete nvarchar(max)18  DECLARE @SQLCmdInsert nvarchar(max)19  DECLARE @UID_BaseTreeHasObject varchar(38)20  DECLARE @SQLCmdBaetreeHasObject nvarchar(max)21  DECLARE @uid_personwantsorg varchar(38)22  DECLARE @BasisObjectKey varchar(138)23  DECLARE @TargetTable varchar(30)24  DECLARE @TargetView varchar(30)25  DECLARE @uid_DialogTableAssigned varchar(38)26  DECLARE @pkname varchar(30)27  DECLARE @DebugSwitch int = 028  DECLARE @DebugLevel char(1) = 'W'29  DECLARE @DebugMessage nvarchar(2000)30  DECLARE @StringQERFGIBitPatternInheritInfo_Direct nvarchar(100)31  DECLARE @GenProcID varchar(38)32  DECLARE @ElementBuffer QBM_YCursorBuffer33  DECLARE @ElementCount int34  DECLARE @ElementIndex int35  DECLARE @PWOsToMove QBM_YParameterList36  DECLARE @QER_BitPatternInherit_Direct int = dbo.QER_FGIBitPatternInheritInfo('|Direct|',37  0)38  SET XACT_ABORT OFF39  BEGIN TRY40    SELECT @GenProcID = dbo.QBM_FGISessionContext('')41    SELECT42      @StringQERFGIBitPatternInheritInfo_Direct = dbo.QBM_FCVBinaryToString(convert(varbinary, dbo.QER_FGIBitPatternInheritInfo('|Direct|',43      0)),44      0)45    SELECT @uid_orgBO_Old = NULL46    SELECT @uid_orgSH_Old = NULL47    SELECT @uid_orgCU_Old = NULL48    SELECT49      TOP 1 @uid_orgBO_Old = bo.uid_org,50      @uid_orgSH_Old = sh.uid_org,51      @uid_orgCU_Old = cu.uid_org,52      @Ident_OrgBO_New = bo.Ident_Org,53      @Ident_OrgSH_New = sh.Ident_Org,54      @UID_AccProduct = pr.UID_AccProduct55    FROM BaseTree pr56    JOIN BaseTree bo57      ON pr.uid_parentorg = bo.uid_org58    JOIN BaseTree sh59      ON bo.uid_parentorg = sh.uid_org60    JOIN BaseTree cu61      ON cu.uid_parentorg = sh.uid_org AND cu.itShopInfo = 'CU'62    WHERE63      pr.uid_org = @uid_OrgPR_Old AND pr.uid_OrgRoot = 'QER-V-ITShopOrg'64    IF @uid_orgBO_Old IS NULL65    BEGIN66      RAISERROR('#LDS#The shelf can not be found for the product node.|',67      18,68      2)69        WITH nowait70    END71    IF @uid_orgSH_Old IS NULL72    BEGIN73      RAISERROR('#LDS#The shop cannot be found for the product node.|',74      18,75      2)76        WITH nowait77    END78    IF @uid_orgCU_Old IS NULL79    BEGIN80      RAISERROR('#LDS#The customer node cannot be found for the product node.|',81      18,82      2)83        WITH nowait84    END85    IF NOT EXISTS(86      SELECT TOP 1 187      FROM BaseTree88      WHERE89        uid_OrgRoot = 'QER-V-ITShopOrg' AND ITShopInfo = 'BO' AND uid_Org = @uid_orgBO_new)90    BEGIN91      RAISERROR('#LDS#The given target node is not a shelf in IT Shop.|',92      18,93      2)94        WITH nowait95    END96    IF @uid_orgBO_Old = @uid_orgBO_New97    BEGIN98      GOTO ende99    END100    SELECT @ObjectKeyElement = NULL101    SELECT TOP 1 @ObjectKeyElement = bho.ObjectKey102    FROM BaseTreeHasObject bho103    WHERE104      bho.UID_Org = @uid_OrgPR_Old AND InheritInfo = @QER_BitPatternInherit_Direct105    IF @Debugswitch > 0106    BEGIN107      SELECT108        @DebugMessage = '@ObjectKeyElement  ' + ISNULL(@ObjectKeyElement,109        '<null>')110      EXEC QBM_PJournal @debugmessage,111        @@procid,112      'D',113        @DebugLevel114    END115    SELECT TOP 1 @TargetTable = tmn.TableName116    FROM BaseTreeAssign ba117    JOIN DialogTable tb118      WITH(readpast)119      ON ba.UID_DialogTableElement = tb.UID_DialogTable120    JOIN DialogTable tmn121      WITH(readpast)122      ON ba.UID_DialogTableMN = tmn.UID_DialogTable123    WHERE124      @ObjectKeyElement LIKE CONCAT('<Key><T>',125    tb.TableName,126    '</T>%')127    IF @Debugswitch > 0128    BEGIN129      SELECT130        @DebugMessage = '@TargetTable  ' + ISNULL(@TargetTable,131        '<null>')132      EXEC QBM_PJournal @debugmessage,133        @@procid,134      'D',135        @DebugLevel136    END137    SELECT138      TOP 1 @pkname = dbo.QBM_FGIPrimaryKeyName_F(@TargetTable,139      1)140    IF @pkname = 'uid_org'141    BEGIN142      SELECT143        TOP 1 @pkname = dbo.QBM_FGIPrimaryKeyName_F(@TargetTable,144        2)145    END146    IF @DebugSwitch > 0147    BEGIN148      SELECT149        @DebugMessage = '@pkname  ' + ISNULL(@pkname,150        '<null>')151      EXEC QBM_PJournal @debugmessage,152        @@procid,153      'D',154        @DebugLevel155    END156    SELECT157      @SQLCmdDelete = 'update ' + @TargetTable + '158				set XOrigin = 0159			where uid_Org = ''' + @uid_OrgBO_Old + '''160			 and ' + @pkname + '  = '''161      + dbo.QBM_FCVObjectkeyToElement('ColumnValue1',162      @ObjectKeyElement) + '''163164			delete ' + @TargetTable + '165			where uid_Org = ''' + @uid_OrgBO_Old + '''166			 and ' + @pkname + '  = ''' + dbo.QBM_FCVObjectkeyToElement167      ('ColumnValue1',168      @ObjectKeyElement) + ''''169    IF @Debugswitch > 0170    BEGIN171      SELECT172        @DebugMessage = '@SQLCmdDelete  ' + ISNULL(@SQLCmdDelete,173        '<null>')174      EXEC QBM_PJournal @debugmessage,175        @@procid,176      'D',177        @DebugLevel178    END179    IF @ObjectKeyElement IS NULL180    BEGIN181      RAISERROR('#LDS#The product could not be found for the given product node.|',182      18,183      2)184        WITH nowait185    END186    IF @uid_accProduct IS NULL187    BEGIN188      RAISERROR('#LDS#Associate Accproduct could not be found.|',189      18,190      2)191        WITH nowait192    END193    SELECT TOP 1 @TargetView = v.TableName194    FROM OrgRootAssign oa195    JOIN BaseTreeAssign ba196      ON oa.UID_BaseTreeAssign = ba.UID_BaseTreeAssign197    JOIN DialogTable v198      WITH(readpast)199      ON v.UID_DialogTableBase = ba.UID_DialogTableMN200    JOIN QBM_VQBMRelation r201      ON r.UID_DialogTableParent = 'QER-T-ITShopOrg' AND r.UID_DialogTableChild = v.UID_DialogTable202    WHERE203      oa.UID_OrgRoot = 'QER-V-ITShopOrg' AND dbo.QBM_FGITableName(ba.UID_DialogTableMN) = @TargetTable204    IF @Debugswitch > 0205    BEGIN206      SELECT207        @DebugMessage = '@TargetView  ' + ISNULL(@TargetView,208        '<null>')209      EXEC QBM_PJournal @debugmessage,210        @@procid,211      'D',212        @DebugLevel213    END214    SELECT215      @SQLCmdInsert = N '216 if not exists (select top 1 1217				 from ' + @TargetTable + '218				 where XObjectKey = ''' + dbo.QBM_FCVElementToObjectKey2219      (@TargetView,220      'UID_ITShopOrg',221      @uid_orgBO_New,222      @pkname,223      dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement)) + '''224			   )225	begin226		insert into ' + @TargetTable + '227		(uid_org, ' + @pkname228      + '229		 , Xorigin, XDateinserted, XdateUpdated230		 , XUserInserted, XUserupdated231		 , XObjectKey232					 ) 233		select ''' + @uid_orgBO_New + ''', '''234      + dbo.QBM_FCVObjectkeyToElement('ColumnValue1',235      @ObjectKeyElement) + '''236		 , 1, ''' + dbo.QBM_FCVDatetimeToString(getutcdate()) + ''', ''' + dbo.QBM_FCVDatetimeToString(getutcdate()) + '''237		, '''238      + OBJECT_NAME(@@procid) + ''', ''' + OBJECT_NAME(@@procid) + '''239		, ''' + dbo.QBM_FCVElementToObjectKey2(@TargetView,240      'UID_ITShopOrg',241      @uid_orgBO_New,242      @pkname,243      dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement)) + '''244	end245	246	'247    IF @Debugswitch > 0248    BEGIN249      SELECT250        @DebugMessage = '@SQLCmdInsert  ' + ISNULL(@SQLCmdInsert,251        '<null>')252      EXEC QBM_PJournal @debugmessage,253        @@procid,254      'D',255        @DebugLevel256    END257    EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdInsert,258      @LockTimeout_ms = 250,259      @MaxWaitTimeForLock_s = 20,260      @ProcIDForJournal = DEFAULT,261      @HandleErrorSilent = 0262    SELECT263      @UID_BaseTreeHasObject = dbo.QBM_FCVStringToGUIDMAll(NULL,264      @uid_orgBO_New,265      @ObjectKeyElement)266    SELECT267      @SQLCmdBaetreeHasObject = '268	insert into BaseTreeHasObject (UID_BaseTreeHasObject, UID_Org, ObjectKey269									, InheritInfo, XObjectKey270								)271		select '''272      + @UID_BaseTreeHasObject + ''', ''' + @uid_orgBO_New + ''', ''' + @ObjectKeyElement + '''273									, ' + @StringQERFGIBitPatternInheritInfo_Direct274      + ' , dbo.QBM_FCVElementToObjectKey1(''BaseTreeHasObject'', ''UID_BaseTreeHasObject'', ''' + @UID_BaseTreeHasObject + ''')275		where Not exists (select top 1 1276							from BaseTreeHasObject bho277							where bho.UID_Org = '''278      + @uid_orgBO_New + '''279							and bho.ObjectKey = ''' + @ObjectKeyElement + '''280						)281	'282    EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdBaetreeHasObject,283      @LockTimeout_ms = 250,284      @MaxWaitTimeForLock_s = 20,285      @ProcIDForJournal = DEFAULT,286      @HandleErrorSilent = 0287    EXEC QER_PITShopProductNodeCreate @uid_orgBO_New,288      @ObjectKeyElement,289      @GenProcID,290      @uid_OrgPR_New OUTPUT291    SELECT292      @UID_BaseTreeHasObject = dbo.QBM_FCVStringToGUIDMAll(NULL,293      @uid_OrgPR_New,294      @ObjectKeyElement)295    SELECT296      @SQLCmdBaetreeHasObject = '297	insert into BaseTreeHasObject (UID_BaseTreeHasObject, UID_Org, ObjectKey298									, InheritInfo, XObjectKey299								)300		select '''301      + @UID_BaseTreeHasObject + ''', ''' + @uid_OrgPR_New + ''', ''' + @ObjectKeyElement + '''302									, ' + @StringQERFGIBitPatternInheritInfo_Direct303      + ' , dbo.QBM_FCVElementToObjectKey1(''BaseTreeHasObject'', ''UID_BaseTreeHasObject'', ''' + @UID_BaseTreeHasObject + ''')304		where Not exists (select top 1 1305							from BaseTreeHasObject bho306							where bho.UID_Org = '''307      + @uid_OrgPR_New + '''308							and bho.ObjectKey = ''' + @ObjectKeyElement + '''309						)310	'311    EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdBaetreeHasObject,312      @LockTimeout_ms = 250,313      @MaxWaitTimeForLock_s = 20,314      @ProcIDForJournal = DEFAULT,315      @HandleErrorSilent = 0316    IF @Debugswitch > 0317    BEGIN318      SELECT319        @DebugMessage = '@uid_OrgPR_New  ' + ISNULL(@uid_OrgPR_New,320        '<null>')321      EXEC QBM_PJournal @debugmessage,322        @@procid,323      'D',324        @DebugLevel325    END326    SELECT327      @uid_OrgSH_New = sh.uid_org,328      @uid_OrgCU_New = cu.uid_org,329      @Ident_OrgBO_New = bo.Ident_Org,330      @Ident_OrgSH_New = sh.Ident_Org331    FROM BaseTree pr332    JOIN BaseTree bo333      ON pr.uid_parentorg = bo.uid_org334    JOIN BaseTree sh335      ON bo.uid_parentorg = sh.uid_org336    JOIN BaseTree cu337      ON cu.uid_parentorg = sh.uid_org AND cu.itShopInfo = 'CU'338    WHERE339      pr.uid_org = @uid_OrgPR_New AND pr.uid_OrgRoot = 'QER-V-ITShopOrg'340    INSERT INTO @PWOsToMove(Parameter1,341    Parameter2,342    Parameter3,343    HasContentFull)344    SELECT345      pwo.UID_PersonWantsOrg,346      @uid_orgBO_new,347      @GenProcID,348      0349    FROM PersonWantsOrg pwo350    JOIN QER_VPWOOrderState s351      ON pwo.OrderState = s.OrderState352    WHERE353      pwo.UID_Org = @uid_OrgPR_Old354    ORDER BY pwo.UID_PersonOrdered,355    s.IsClosed DESC,356    s.IsAssigned ASC,357    s.IsOrder ASC,358    s.IsGranted DESC359    EXEC QER_PITShopOrderMove_bulk @PWOsToMove360    EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdDelete,361      @LockTimeout_ms = 500,362      @MaxWaitTimeForLock_s = 20,363      @ProcIDForJournal = DEFAULT,364      @HandleErrorSilent = 0365  END TRY366  BEGIN CATCH367    EXEC QBM_PSessionErrorAdd DEFAULT368    DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()369    RAISERROR(@Rethrow,370    18,371    1)372      WITH NOWAIT373  END CATCH374  ende:375  RETURN376END
Open raw exported source
SQL ยท Raw110 lines
1    create   procedure QER_PITShopProductNodeMove ( @uid_OrgPR_Old varchar(38)  , @uid_orgBO_new varchar(38)  ) as begin declare @uid_OrgPR_New 2varchar(38) declare @uid_OrgSH_New varchar(38) declare @uid_OrgCU_New varchar(38) declare @uid_orgBO_Old varchar(38) declare @uid_orgSH_Old varchar(38)3 declare @uid_orgCU_Old varchar(38) declare @Ident_OrgBO_New nvarchar(256) declare @Ident_OrgSH_New nvarchar(256) declare @ObjectKeyElement varchar(1384)  declare @UID_AccProduct varchar(38) declare @SQLCmdDelete nvarchar(max) declare @SQLCmdInsert nvarchar(max)  declare @UID_BaseTreeHasObject varchar(385) declare @SQLCmdBaetreeHasObject nvarchar(max) declare @uid_personwantsorg varchar(38) declare @BasisObjectKey varchar(138) declare @TargetTable varchar6(30) declare @TargetView varchar(30)  declare @uid_DialogTableAssigned varchar(38) declare @pkname varchar(30) declare @DebugSwitch int = 0 declare @DebugLevel7 char(1) = 'W' declare @DebugMessage nvarchar(2000) declare @StringQERFGIBitPatternInheritInfo_Direct nvarchar(100) declare @GenProcID varchar(38) declare8 @ElementBuffer QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int declare @PWOsToMove QBM_YParameterList    declare @QER_BitPatternInherit_Direct9 int = dbo.QER_FGIBitPatternInheritInfo('|Direct|', 0)  SET XACT_ABORT OFF BEGIN TRY select @GenProcID = dbo.QBM_FGISessionContext('') select @StringQERFGIBitPatternInheritInfo_Direct10 = dbo.QBM_FCVBinaryToString(convert(varbinary, dbo.QER_FGIBitPatternInheritInfo('|Direct|', 0)), 0)  select @uid_orgBO_Old = null select @uid_orgSH_Old11 = null select @uid_orgCU_Old = null select top 1 @uid_orgBO_Old = bo.uid_org, @uid_orgSH_Old = sh.uid_org, @uid_orgCU_Old = cu.uid_org , @Ident_OrgBO_New12 = bo.Ident_Org , @Ident_OrgSH_New = sh.Ident_Org , @UID_AccProduct = pr.UID_AccProduct from BaseTree pr join BaseTree bo on pr.uid_parentorg = bo.uid_org13 join BaseTree sh on bo.uid_parentorg = sh.uid_org join BaseTree cu on cu.uid_parentorg = sh.uid_org and cu.itShopInfo = 'CU' where pr.uid_org = @uid_OrgPR_Old14 and pr.uid_OrgRoot = 'QER-V-ITShopOrg' if @uid_orgBO_Old is null begin  raiserror( '#LDS#The shelf can not be found for the product node.|', 18, 2) with15 nowait end if @uid_orgSH_Old is null begin  raiserror( '#LDS#The shop cannot be found for the product node.|', 18, 2) with nowait end if @uid_orgCU_Old16 is null begin  raiserror( '#LDS#The customer node cannot be found for the product node.|', 18, 2) with nowait end if not exists (select top 1 1 from BaseTree17 where uid_OrgRoot = 'QER-V-ITShopOrg' and ITShopInfo = 'BO' and uid_Org = @uid_orgBO_new ) begin  raiserror( '#LDS#The given target node is not a shelf in IT Shop.|'18, 18, 2) with nowait end if @uid_orgBO_Old = @uid_orgBO_New begin  goto ende end select @ObjectKeyElement = null  select top 1 @ObjectKeyElement = bho.ObjectKey19 from BaseTreeHasObject bho where bho.UID_Org = @uid_OrgPR_Old  and InheritInfo = @QER_BitPatternInherit_Direct if @Debugswitch > 0 begin select @DebugMessage20 = '@ObjectKeyElement  '+ ISNULL(@ObjectKeyElement, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel end  select top 1 @TargetTable21 = tmn.TableName from BaseTreeAssign ba join DialogTable tb with (readpast) on ba.UID_DialogTableElement = tb.UID_DialogTable join DialogTable tmn with22 (readpast) on ba.UID_DialogTableMN = tmn.UID_DialogTable  where @ObjectKeyElement like concat('<Key><T>' , tb.TableName , '</T>%') if @Debugswitch > 023 begin select @DebugMessage = '@TargetTable  '+ ISNULL(@TargetTable, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel end select top24 1 @pkname = dbo.QBM_FGIPrimaryKeyName_F(@TargetTable,1) if @pkname = 'uid_org' begin select top 1 @pkname = dbo.QBM_FGIPrimaryKeyName_F(@TargetTable,225) end if @DebugSwitch > 0 begin select @DebugMessage = '@pkname  '+ ISNULL(@pkname, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel26 end  select @SQLCmdDelete = 'update ' + @TargetTable + '27				set XOrigin = 028			where uid_Org = ''' + @uid_OrgBO_Old + '''29			 and ' + @pkname + '  = '''30 + dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement) + '''3132			delete ' + @TargetTable + '33			where uid_Org = ''' + @uid_OrgBO_Old + 34'''35			 and ' + @pkname + '  = ''' + dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement) + ''''    if @Debugswitch > 0 begin select @DebugMessage36 = '@SQLCmdDelete  '+ ISNULL(@SQLCmdDelete, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel end if @ObjectKeyElement is null begin37  raiserror( '#LDS#The product could not be found for the given product node.|', 18, 2) with nowait end if @uid_accProduct is Null begin  raiserror( '#LDS#Associate Accproduct could not be found.|'38, 18, 2) with nowait end  select top 1 @TargetView = v.TableName from OrgRootAssign oa join BaseTreeAssign ba on oa.UID_BaseTreeAssign = ba.UID_BaseTreeAssign39 join DialogTable v with (readpast) on v.UID_DialogTableBase = ba.UID_DialogTableMN join QBM_VQBMRelation r on r.UID_DialogTableParent = 'QER-T-ITShopOrg'40 and r.UID_DialogTableChild = v.UID_DialogTable where oa.UID_OrgRoot = 'QER-V-ITShopOrg' and dbo.QBM_FGITableName(ba.UID_DialogTableMN) = @TargetTable 41if @Debugswitch > 0 begin select @DebugMessage = '@TargetView  '+ ISNULL(@TargetView, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel42 end select @SQLCmdInsert = N'43 if not exists (select top 1 144				 from ' + @TargetTable + '45				 where XObjectKey = ''' + dbo.QBM_FCVElementToObjectKey246(@TargetView, 'UID_ITShopOrg',@uid_orgBO_New, @pkname,dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement)) + '''47			   )48	begin49		insert into '50 + @TargetTable + '51		(uid_org, ' + @pkname + '52		 , Xorigin, XDateinserted, XdateUpdated53		 , XUserInserted, XUserupdated54		 , XObjectKey55					 ) 56		select '''57 + @uid_orgBO_New + ''', ''' + dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement) + '''58		 , 1, ''' + dbo.QBM_FCVDatetimeToString(getutcdate59()) + ''', ''' + dbo.QBM_FCVDatetimeToString(getutcdate()) + '''60		, ''' + OBJECT_NAME(@@procid) + ''', ''' + OBJECT_NAME(@@procid) + '''61		, ''' + dbo.QBM_FCVElementToObjectKey262(@TargetView, 'UID_ITShopOrg',@uid_orgBO_New, @pkname,dbo.QBM_FCVObjectkeyToElement('ColumnValue1', @ObjectKeyElement)) + '''63	end64	65	'  if @Debugswitch66 > 0 begin select @DebugMessage = '@SQLCmdInsert  '+ ISNULL(@SQLCmdInsert, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel end exec67 QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdInsert , @LockTimeout_ms = 250 , @MaxWaitTimeForLock_s = 20 , @ProcIDForJournal = default , @HandleErrorSilent68 = 0 select @UID_BaseTreeHasObject = dbo.QBM_FCVStringToGUIDMAll(null, @uid_orgBO_New, @ObjectKeyElement) select @SQLCmdBaetreeHasObject = '69	insert into BaseTreeHasObject (UID_BaseTreeHasObject, UID_Org, ObjectKey70									, InheritInfo, XObjectKey71								)72		select '''73 + @UID_BaseTreeHasObject + ''', ''' + @uid_orgBO_New + ''', ''' + @ObjectKeyElement + '''74									, ' + @StringQERFGIBitPatternInheritInfo_Direct + 75' , dbo.QBM_FCVElementToObjectKey1(''BaseTreeHasObject'', ''UID_BaseTreeHasObject'', ''' + @UID_BaseTreeHasObject + ''')76		where Not exists (select top 1 177							from BaseTreeHasObject bho78							where bho.UID_Org = '''79 + @uid_orgBO_New + '''80							and bho.ObjectKey = ''' + @ObjectKeyElement + '''81						)82	' exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdBaetreeHasObject83 , @LockTimeout_ms = 250 , @MaxWaitTimeForLock_s = 20 , @ProcIDForJournal = default , @HandleErrorSilent = 0 exec QER_PITShopProductNodeCreate @uid_orgBO_New84, @ObjectKeyElement, @GenProcID, @uid_OrgPR_New output  select @UID_BaseTreeHasObject = dbo.QBM_FCVStringToGUIDMAll(null, @uid_OrgPR_New, @ObjectKeyElement85) select @SQLCmdBaetreeHasObject = '86	insert into BaseTreeHasObject (UID_BaseTreeHasObject, UID_Org, ObjectKey87									, InheritInfo, XObjectKey88								)89		select '''90 + @UID_BaseTreeHasObject + ''', ''' + @uid_OrgPR_New + ''', ''' + @ObjectKeyElement + '''91									, ' + @StringQERFGIBitPatternInheritInfo_Direct + 92' , dbo.QBM_FCVElementToObjectKey1(''BaseTreeHasObject'', ''UID_BaseTreeHasObject'', ''' + @UID_BaseTreeHasObject + ''')93		where Not exists (select top 1 194							from BaseTreeHasObject bho95							where bho.UID_Org = '''96 + @uid_OrgPR_New + '''97							and bho.ObjectKey = ''' + @ObjectKeyElement + '''98						)99	' exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLCmdBaetreeHasObject100 , @LockTimeout_ms = 250 , @MaxWaitTimeForLock_s = 20 , @ProcIDForJournal = default , @HandleErrorSilent = 0 if @Debugswitch > 0 begin select @DebugMessage101 = '@uid_OrgPR_New  '+ ISNULL(@uid_OrgPR_New, '<null>') exec QBM_PJournal @debugmessage, @@procid, 'D', @DebugLevel end  select @uid_OrgSH_New = sh.uid_org102, @uid_OrgCU_New = cu.uid_org , @Ident_OrgBO_New = bo.Ident_Org , @Ident_OrgSH_New = sh.Ident_Org from BaseTree pr join BaseTree bo on pr.uid_parentorg103 = bo.uid_org join BaseTree sh on bo.uid_parentorg = sh.uid_org join BaseTree cu on cu.uid_parentorg = sh.uid_org and cu.itShopInfo = 'CU' where pr.uid_org104 = @uid_OrgPR_New and pr.uid_OrgRoot = 'QER-V-ITShopOrg'  insert into @PWOsToMove (Parameter1, Parameter2, Parameter3, HasContentFull) select pwo.UID_PersonWantsOrg105 , @uid_orgBO_new, @GenProcID, 0 from PersonWantsOrg pwo join QER_VPWOOrderState  s on pwo.OrderState = s.OrderState where pwo.UID_Org = @uid_OrgPR_Old106  order by pwo.UID_PersonOrdered, s.IsClosed desc, s.IsAssigned asc, s.IsOrder asc, s.IsGranted desc exec QER_PITShopOrderMove_bulk @PWOsToMove  exec QBM_PExecuteSQLWithRetry_LLP107 @SQLStatement = @SQLCmdDelete , @LockTimeout_ms = 500 , @MaxWaitTimeForLock_s = 20 , @ProcIDForJournal = default , @HandleErrorSilent = 0  END TRY BEGIN108 CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END 109CATCH  ende: return end 110