dbo.QER_PITShop_BoardMove
Stored ProcedureSQL_STORED_PROCEDURESandbox DB
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_FCVElementToObjectKey1 source text reference
- references source dbo.QBM_FCVElementToObjectKey2 source text reference
- references source dbo.QBM_FGIGuidIsValid source text reference
- references source dbo.QBM_FGISessionContext source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
- references source dbo.QER_PITShop_PRNodesMove source text reference
- references source dbo.QER_PITShopCheckMethodBO source text reference
- references source dbo.QER_PITShopProductNodeCheck source text reference
Complete Source
1CREATE PROCEDURE QER_PITShop_BoardMove(2 @UID_OrgBOSource varchar(38),3 @UID_OrgSHTarget varchar(38)4)5AS6BEGIN7 DECLARE @uid_OrgCU_Target varchar(38)8 DECLARE @uid_OrgBO_Target varchar(38)9 DECLARE @uid_orgSH_Source varchar(38)10 DECLARE @WhereClause nvarchar(max)11 DECLARE @startat datetime12 DECLARE @PRNodes QBM_YSingleGUID13 DECLARE @GenProcID varchar(38)14 DECLARE @FullPathSHTarget nvarchar(400)15 SET XACT_ABORT OFF16 BEGIN TRY17 SELECT @GenProcID = dbo.QBM_FGISessionContext('')18 SELECT @uid_orgSH_Source = NULL19 SELECT TOP 1 @uid_orgSH_Source = sh.uid_org20 FROM BaseTree bo21 JOIN BaseTree sh22 ON bo.uid_parentorg = sh.uid_org23 LEFT24 OUTER25 JOIN BaseTree cu26 ON cu.uid_parentorg = sh.uid_org AND cu.itShopInfo = 'CU'27 WHERE28 bo.uid_org = @UID_OrgBOSource AND bo.uid_OrgRoot = 'QER-V-ITShopOrg' AND bo.ITShopInfo = 'BO'29 IF @uid_orgSH_Source IS NULL30 BEGIN31 RAISERROR('#LDS#The shop cannot be found for the shelf (source).|',32 18,33 2)34 WITH nowait35 END36 IF NOT EXISTS(37 SELECT TOP 1 138 FROM BaseTree39 WHERE40 uid_OrgRoot = 'QER-V-ITShopOrg' AND ITShopInfo = 'SH' AND uid_Org = @UID_OrgSHTarget)41 BEGIN42 RAISERROR('#LDS#The given target node is not an IT Shop.|',43 18,44 2)45 WITH nowait46 END47 IF @uid_orgSH_Source = @UID_OrgSHTarget48 BEGIN49 GOTO ende50 END51 IF NOT EXISTS(52 SELECT TOP 1 153 FROM BaseTree54 WHERE55 uid_OrgRoot = 'QER-V-ITShopOrg' AND ITShopInfo = 'BO' AND uid_Org = @UID_OrgBOSource AND dbo.QBM_FGIGuidIsValid(uid_Org) & 2 = 0)56 BEGIN57 RAISERROR('#LDS#The given shelf (source) must not be moved to another shop.|',58 18,59 2)60 WITH nowait61 END62 IF EXISTS(63 SELECT TOP 1 164 FROM BaseTree targetBO65 WHERE66 targetBO.uid_OrgRoot = 'QER-V-ITShopOrg' AND targetBO.ITShopInfo = 'BO' AND targetBO.uid_ParentOrg = @UID_OrgSHTarget AND targetBO.Ident_Org67 IN(68 SELECT Ident_Org69 FROM Basetree70 WHERE71 uid_org = @UID_OrgBOSource))72 BEGIN73 RAISERROR('#LDS#The selected shop already contains a shelf with the same name as the IT Shop node.|',74 18,75 2)76 WITH nowait77 END78 SELECT TOP 1 @FullPathSHTarget = fullpath79 FROM Basetree80 WHERE81 UID_Org = @UID_OrgSHTarget82 SELECT @uid_OrgBO_Target = newid()83 INSERT INTO BaseTree(UID_Org,84 UID_ParentOrg,85 Ident_Org,86 IsCutNode,87 Description,88 uid_OrgRoot,89 UID_PersonHead,90 UID_PersonHeadSecond,91 UID_OrgDepartment,92 UID_OrgLocality,93 UID_OrgProfitCenter,94 UID_OrgAttestator,95 XDateInserted,96 XDateUpdated,97 XUserInserted,98 XUserUpdated,99 InternalName,100 FullPath,101 Commentary,102 ITShopInfo,103 XObjectKey,104 IsInvalidForDynamicGroup,105 UID_PWODecisionMethod)106 SELECT107 @uid_OrgBO_Target,108 @UID_OrgSHTarget,109 b.Ident_Org,110 0,111 b.Description,112 b.UID_OrgRoot,113 b.UID_PersonHead,114 b.UID_PersonHeadSecond,115 b.UID_OrgDepartment,116 b.UID_OrgLocality,117 b.UID_OrgProfitCenter,118 b.UID_OrgAttestator,119 GetUTCDate(),120 GetUTCDate(),121 'QER_PITShopBoardMove',122 'QER_PITShopBoardMove',123 b.InternalName,124 CONCAT(@FullPathSHTarget,125 '\',126 b.Ident_Org),127 b.Commentary,128 'BO',129 dbo.QBM_FCVElementToObjectKey1('ITShopOrg',130 'UID_ITShopOrg',131 @uid_OrgBO_Target),132 1,133 b.UID_PWODecisionMethod134 FROM Basetree b135 WHERE136 b.uid_org = @UID_OrgBOSource137 INSERT INTO ITShopOrgHasPWODecisionMethod(UID_ITShopOrg,138 UID_PWODecisionMethod,139 XObjectkey,140 XDateInserted,141 XDateUpdated,142 XUserInserted,143 XUserUpdated)144 SELECT145 @uid_OrgBO_Target,146 o.UID_PWODecisionMethod,147 dbo.QBM_FCVElementToObjectKey2('ITShopOrgHasPWODecisionMethod',148 'UID_ITShopOrg',149 @uid_OrgBO_Target,150 'UID_PWODecisionMethod',151 o.UID_PWODecisionMethod),152 GetUTCDate(),153 GetUTCDate(),154 'QER_PITShopBoardMove',155 'QER_PITShopBoardMove'156 FROM ITShopOrgHasPWODecisionMethod o157 WHERE158 o.UID_ITShopOrg = @UID_OrgBOSource159 DECLARE @Boards QBM_YCursorBuffer160 INSERT INTO @Boards(UID1,161 UID2)162 SELECT163 @uid_OrgBO_Target,164 @GenProcID165 EXEC QER_PITShopCheckMethodBO @Boards166 INSERT INTO @PRNodes(UID_SingleGuid)167 SELECT pr.UID_ITShopOrg168 FROM ITShopOrg pr169 WHERE170 pr.UID_ParentITShopOrg = @UID_OrgBOSource AND pr.ITShopInfo = 'PR'171 EXEC QER_PITShop_PRNodesMove @PRNodes,172 @uid_OrgBO_Target173 EXEC QER_PITShopProductNodeCheck @UID_OrgBOSource,174 @GenProcID175 DELETE Basetree176 WHERE177 uid_org = @UID_OrgBOSource178 END TRY179 BEGIN CATCH180 EXEC QBM_PSessionErrorAdd DEFAULT181 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()182 RAISERROR(@Rethrow,183 18,184 1)185 WITH NOWAIT186 END CATCH187 ende:188 RETURN189END
Open raw exported source
1 create procedure QER_PITShop_BoardMove (@UID_OrgBOSource varchar(38) , @UID_OrgSHTarget varchar(38) ) as begin declare @uid_OrgCU_Target 2varchar(38) declare @uid_OrgBO_Target varchar(38) declare @uid_orgSH_Source varchar(38) declare @WhereClause nvarchar(max) declare @startat datetime declare3 @PRNodes QBM_YSingleGUID declare @GenProcID varchar(38) declare @FullPathSHTarget nvarchar(400) SET XACT_ABORT OFF BEGIN TRY select @GenProcID = dbo.QBM_FGISessionContext4('') select @uid_orgSH_Source = null select top 1 @uid_orgSH_Source = sh.uid_org from BaseTree bo join BaseTree sh on bo.uid_parentorg = sh.uid_org 5left outer join BaseTree cu on cu.uid_parentorg = sh.uid_org and cu.itShopInfo = 'CU' where bo.uid_org = @UID_OrgBOSource and bo.uid_OrgRoot = 'QER-V-ITShopOrg'6 and bo.ITShopInfo = 'BO' if @uid_orgSH_Source is null begin raiserror( '#LDS#The shop cannot be found for the shelf (source).|', 18, 2) with nowait end7 if not exists (select top 1 1 from BaseTree where uid_OrgRoot = 'QER-V-ITShopOrg' and ITShopInfo = 'SH' and uid_Org = @UID_OrgSHTarget ) begin raiserror8( '#LDS#The given target node is not an IT Shop.|', 18, 2) with nowait end if @uid_orgSH_Source = @UID_OrgSHTarget begin goto ende end if not exists9 (select top 1 1 from BaseTree where uid_OrgRoot = 'QER-V-ITShopOrg' and ITShopInfo = 'BO' and uid_Org = @UID_OrgBOSource and dbo.QBM_FGIGuidIsValid(uid_Org10) & 2 = 0 ) begin raiserror( '#LDS#The given shelf (source) must not be moved to another shop.|', 18, 2) with nowait end if exists (select top 1 1 from11 BaseTree targetBO where targetBO.uid_OrgRoot = 'QER-V-ITShopOrg' and targetBO.ITShopInfo = 'BO' and targetBO.uid_ParentOrg = @UID_OrgSHTarget and targetBO.Ident_Org12 in (select Ident_Org from Basetree where uid_org = @UID_OrgBOSource) ) begin raiserror( '#LDS#The selected shop already contains a shelf with the same name as the IT Shop node.|'13, 18, 2) with nowait end select top 1 @FullPathSHTarget = fullpath from Basetree where UID_Org = @UID_OrgSHTarget select @uid_OrgBO_Target = newid() 14insert into BaseTree( UID_Org, UID_ParentOrg, Ident_Org , IsCutNode, Description , uid_OrgRoot , UID_PersonHead, UID_PersonHeadSecond, UID_OrgDepartment15, UID_OrgLocality, UID_OrgProfitCenter, UID_OrgAttestator , XDateInserted , XDateUpdated , XUserInserted , XUserUpdated, InternalName , FullPath ,Commentary16 , ITShopInfo , XObjectKey , IsInvalidForDynamicGroup , UID_PWODecisionMethod ) select @uid_OrgBO_Target, @UID_OrgSHTarget, b.Ident_Org, 0, b.Description17, b.UID_OrgRoot , b.UID_PersonHead, b.UID_PersonHeadSecond, b.UID_OrgDepartment, b.UID_OrgLocality, b.UID_OrgProfitCenter, b.UID_OrgAttestator , GetUTCDate18(), GetUTCDate(), 'QER_PITShopBoardMove', 'QER_PITShopBoardMove', b.InternalName, concat(@FullPathSHTarget, '\', b.Ident_Org), b.Commentary , 'BO', dbo.QBM_FCVElementToObjectKey119('ITShopOrg', 'UID_ITShopOrg', @uid_OrgBO_Target) , 1 , b.UID_PWODecisionMethod from Basetree b where b.uid_org = @UID_OrgBOSource insert20 into ITShopOrgHasPWODecisionMethod (UID_ITShopOrg, UID_PWODecisionMethod , XObjectkey , XDateInserted, XDateUpdated, XUserInserted, XUserUpdated ) select21 @uid_OrgBO_Target, o.UID_PWODecisionMethod , dbo.QBM_FCVElementToObjectKey2('ITShopOrgHasPWODecisionMethod', 'UID_ITShopOrg', @uid_OrgBO_Target, 'UID_PWODecisionMethod'22, o.UID_PWODecisionMethod) , GetUTCDate(), GetUTCDate(), 'QER_PITShopBoardMove', 'QER_PITShopBoardMove' from ITShopOrgHasPWODecisionMethod o where o.UID_ITShopOrg23 = @UID_OrgBOSource declare @Boards QBM_YCursorBuffer insert into @Boards(UID1, UID2) select @uid_OrgBO_Target, @GenProcID exec QER_PITShopCheckMethodBO24 @Boards insert into @PRNodes (UID_SingleGuid) select pr.UID_ITShopOrg from ITShopOrg pr where pr.UID_ParentITShopOrg = @UID_OrgBOSource and pr.ITShopInfo25 = 'PR' exec QER_PITShop_PRNodesMove @PRNodes, @uid_OrgBO_Target exec QER_PITShopProductNodeCheck @UID_OrgBOSource, @GenProcID delete Basetree 26where uid_org = @UID_OrgBOSource END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow(27) RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH ende: return end 28