Enhanced: queries for converting 16-32bit link data at procedure level
This commit is contained in:
parent
cc6735db05
commit
50fce8d002
@ -12653,6 +12653,269 @@ IF (@@Error = 0) PRINT 'StoredProcedure [vesp_PurgeEnhancedDocVersionsAndChildre
|
|||||||
ELSE PRINT 'StoredProcedure [vesp_PurgeEnhancedDocVersionsAndChildren] Error on Creation'
|
ELSE PRINT 'StoredProcedure [vesp_PurgeEnhancedDocVersionsAndChildren] Error on Creation'
|
||||||
go
|
go
|
||||||
|
|
||||||
|
-- AddToPromsFixes_Convert16to32
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_GetOldEnhancedProcItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||||
|
DROP FUNCTION [vefn_GetOldEnhancedProcItems];
|
||||||
|
GO
|
||||||
|
/*
|
||||||
|
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17012)
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17066)
|
||||||
|
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17012) VE
|
||||||
|
join vefn_GetOldEnhancedProcItems(17066) VS on ve.Procname = vs.ProcName and substring(VE.RecID,3,8) = substring(VS.RecID,3,8)
|
||||||
|
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17014)
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17015)
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17029)
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17033)
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(17045)
|
||||||
|
select * from vefn_GetOldEnhancedProcItems(99043)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*****************************************************************************
|
||||||
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
|
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
|
||||||
|
*****************************************************************************/
|
||||||
|
CREATE FUNCTION [dbo].[vefn_GetOldEnhancedProcItems](@ItemID as int)
|
||||||
|
RETURNS @Enhanced TABLE
|
||||||
|
(
|
||||||
|
ItemID int,
|
||||||
|
ContentID int,
|
||||||
|
ProcName varchar(255),
|
||||||
|
RecID varchar(10)
|
||||||
|
)
|
||||||
|
WITH EXECUTE AS OWNER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
declare @ProcNum varchar(255)
|
||||||
|
select @ProcNum = replace(Number,'\u8209?','-') from contents CC
|
||||||
|
join Items II on II.ContentID = CC.ContentID
|
||||||
|
Where ItemID = @ItemID
|
||||||
|
Begin
|
||||||
|
with Itemz([FromType], [Level], [ItemID], [ContentID]) as (
|
||||||
|
Select 1 [FromType], 0 [Level], [ItemID], [ContentID]
|
||||||
|
FROM [Items]
|
||||||
|
where [ItemID]=@ItemID
|
||||||
|
Union All -- Children
|
||||||
|
select P.FromType, [Level] + 1, I.[ItemID], I.[ContentID]
|
||||||
|
from Itemz Z
|
||||||
|
join Parts P on P.ContentID = Z.ContentID
|
||||||
|
join Items I on I.ItemID = P.ItemID
|
||||||
|
where Z.FromType <= 2
|
||||||
|
or P.FromType in (3,4)
|
||||||
|
Union All -- Siblings
|
||||||
|
select Z.FromType, [Level] , I.[ItemID], I.[ContentID]
|
||||||
|
from Itemz Z
|
||||||
|
join Items I on I.PreviousID = Z.ItemID
|
||||||
|
where Z.[Level] > 0
|
||||||
|
)
|
||||||
|
Insert into @Enhanced
|
||||||
|
select ItemID,ContentID,ProcName,RecID from ( select II.ItemID,II.ContentID
|
||||||
|
, isnull(xHistory.value('@ProcName','varchar(255)'),@ProcNum) ProcName
|
||||||
|
, xHistory.value('@RecID','varchar(255)') RecID
|
||||||
|
, Row_Number() over (partition by isnull(xHistory.value('@ProcName','varchar(255)'),@ProcNum)
|
||||||
|
, xHistory.value('@RecID','varchar(255)') order by ItemID) RowOrder
|
||||||
|
from Itemz II
|
||||||
|
Join (select *, Cast(config as xml) xConfig from Contents) CC ON CC.ContentID = II.ContentID
|
||||||
|
Cross Apply xConfig.nodes('//History') tHistory(xHistory)
|
||||||
|
) T1
|
||||||
|
where RowOrder = 1
|
||||||
|
OPTION (MAXRECURSION 10000)
|
||||||
|
END
|
||||||
|
RETURN
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
IF (@@Error = 0) PRINT 'TableFunction [vefn_GetOldEnhancedProcItems] Succeeded'
|
||||||
|
ELSE PRINT 'TableFunction [vefn_GetOldEnhancedProcItems] Error on Creation'
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_Get16to32EnhancedProcItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||||
|
DROP FUNCTION [vefn_Get16to32EnhancedProcItems];
|
||||||
|
GO
|
||||||
|
/*
|
||||||
|
|
||||||
|
select * from vefn_Get16to32EnhancedProcItems(17012,17066,1)
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*****************************************************************************
|
||||||
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
|
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
|
||||||
|
*****************************************************************************/
|
||||||
|
CREATE FUNCTION [dbo].[vefn_Get16to32EnhancedProcItems](@SourceID int, @EnhanceID int, @EnhType int)
|
||||||
|
RETURNS @EnhItems TABLE
|
||||||
|
(
|
||||||
|
SrcItemID int,
|
||||||
|
SrcContentID int,
|
||||||
|
SrcConfig varchar(255),
|
||||||
|
ProcName varchar(255),
|
||||||
|
RecID varchar(8),
|
||||||
|
EnhItemID int,
|
||||||
|
EnhContentID int,
|
||||||
|
EnhConfig varchar(255),
|
||||||
|
EnhProcName varchar(255),
|
||||||
|
EnhRecID varchar(8)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
Insert into @EnhItems-- Procedures
|
||||||
|
select @SourceID SrcItemID, (select ContentID from Items Where ItemID = @SourceID) SrcContentID
|
||||||
|
,'<Enhanced Type="' + cast(@EnhType as varchar(12)) + '" ItemID = "' + cast(@EnhanceID as varchar(12)) + '"/>' SrcConfig
|
||||||
|
,isnull(VSO.ProcName,replace(CCS.Number,'\u8209?','-')) SrcProcName, null SrcRecID
|
||||||
|
,@EnhanceID EnhItemID, (select ContentID from Items Where ItemID = @EnhanceID) EnhContentID
|
||||||
|
,'<Enhanced Type="0" ItemID = "' + cast(@SourceID as varchar(12)) + '"/>' EnhConfig
|
||||||
|
,isnull(VEO.ProcName ,replace(CCE.Number,'\u8209?','-')) EnhProcNam, null EnhRecID
|
||||||
|
From vefn_GetOldEnhancedData(@SourceID) VSO
|
||||||
|
cross apply vefn_GetOldEnhancedData(@EnhanceID) VEO
|
||||||
|
JOIN Contents CCS ON VSO.ContentID = CCs.ContentID
|
||||||
|
JOIN Contents CCE ON VEO.ContentID = CCE.ContentID
|
||||||
|
|
||||||
|
Insert into @EnhItems--Sections and Steps
|
||||||
|
select VS.ItemID, VS.ContentID
|
||||||
|
,'<Enhanced Type="' + cast(@EnhType as varchar(12)) + '" ItemID = "' + cast(VE.ItemID as varchar(12)) + '"/>' SrcConfig
|
||||||
|
,VS.ProcName SrcProcName, VS.RecID RecID
|
||||||
|
,VE.ItemID EnhItemID, VE.ContentID EnhContentID
|
||||||
|
,'<Enhanced Type="0" ItemID = "' + cast(VS.ItemID as varchar(12)) + '"/>' EnhConfig
|
||||||
|
,VE.ProcName EnhProcName, VE.RecID EnhRecID
|
||||||
|
from vefn_GetOldEnhancedProcItems(@SourceID) VS
|
||||||
|
join vefn_GetOldEnhancedProcItems(@EnhanceID) VE on ve.Procname = vs.ProcName and substring(VE.RecID,3,8) = substring(VS.RecID,3,8)
|
||||||
|
--select * from @EnhItems
|
||||||
|
RETURN
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
IF (@@Error = 0) PRINT 'TableFunction [vefn_Get16to32EnhancedProcItem] Succeeded'
|
||||||
|
ELSE PRINT 'TableFunction [vefn_Get16to32EnhancedProcItem] Error on Creation'
|
||||||
|
GO
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_Get16BitEnhancedContents]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||||
|
DROP PROCEDURE [vesp_Get16BitEnhancedContents];
|
||||||
|
GO
|
||||||
|
/*
|
||||||
|
|
||||||
|
vesp_Get16BitEnhancedContents 17012,17066,1
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
|
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
|
||||||
|
*****************************************************************************/
|
||||||
|
CREATE PROCEDURE [dbo].[vesp_Get16BitEnhancedContents](@SourceID int, @EnhanceID int, @EnhType int) -- @EnhanceID -- Enhanced VersionID
|
||||||
|
WITH EXECUTE AS OWNER
|
||||||
|
AS
|
||||||
|
BEGIN TRY -- Try Block
|
||||||
|
BEGIN TRANSACTION
|
||||||
|
DECLARE @EnhItems TABLE
|
||||||
|
(
|
||||||
|
SrcItemID int,
|
||||||
|
SrcContentID int,
|
||||||
|
SrcConfig varchar(255),
|
||||||
|
ProcName varchar(255),
|
||||||
|
RecID varchar(8),
|
||||||
|
EnhItemID int,
|
||||||
|
EnhContentID int,
|
||||||
|
EnhConfig varchar(255),
|
||||||
|
EnhProcName varchar(255),
|
||||||
|
EnhRecID varchar(8)
|
||||||
|
)
|
||||||
|
Insert into @EnhItems
|
||||||
|
select * from vefn_Get16to32EnhancedProcItems(@SourceID,@EnhanceID,@EnhType)
|
||||||
|
|
||||||
|
SELECT [ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[LastChanged],
|
||||||
|
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
|
||||||
|
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
|
||||||
|
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
|
||||||
|
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
|
||||||
|
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
|
||||||
|
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
|
||||||
|
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
|
||||||
|
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
|
||||||
|
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
|
||||||
|
FROM [Contents] where ContentID in (Select SrcContentID from @EnhItems union Select EnhContentID from @EnhItems)
|
||||||
|
|
||||||
|
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||||
|
END TRY
|
||||||
|
BEGIN CATCH -- Catch Block
|
||||||
|
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||||
|
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||||
|
EXEC vlnErrorHandler
|
||||||
|
END CATCH
|
||||||
|
GO
|
||||||
|
-- Display the status of Proc creation
|
||||||
|
IF (@@Error = 0) PRINT 'StoredProcedure [vesp_Get16BitEnhancedContents] Succeeded'
|
||||||
|
ELSE PRINT 'StoredProcedure [vesp_Get16BitEnhancedContents] Error on Creation'
|
||||||
|
go
|
||||||
|
|
||||||
|
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_Convert16to32EnhancedContents]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||||
|
DROP PROCEDURE [vesp_Convert16to32EnhancedContents];
|
||||||
|
GO
|
||||||
|
/*
|
||||||
|
|
||||||
|
vesp_Convert16to32EnhancedContents 17012,17066,1
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
|
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
|
||||||
|
*****************************************************************************/
|
||||||
|
CREATE PROCEDURE [dbo].[vesp_Convert16to32EnhancedContents](@SourceID int, @EnhanceID int, @EnhType int) -- @EnhanceID -- Enhanced VersionID
|
||||||
|
WITH EXECUTE AS OWNER
|
||||||
|
AS
|
||||||
|
BEGIN TRY -- Try Block
|
||||||
|
BEGIN TRANSACTION
|
||||||
|
DECLARE @EnhItems TABLE
|
||||||
|
(
|
||||||
|
SrcItemID int,
|
||||||
|
SrcContentID int,
|
||||||
|
SrcConfig varchar(255),
|
||||||
|
ProcName varchar(255),
|
||||||
|
RecID varchar(8),
|
||||||
|
EnhItemID int,
|
||||||
|
EnhContentID int,
|
||||||
|
EnhConfig varchar(255),
|
||||||
|
EnhProcName varchar(255),
|
||||||
|
EnhRecID varchar(8)
|
||||||
|
)
|
||||||
|
Insert into @EnhItems
|
||||||
|
select * from vefn_Get16to32EnhancedProcItems(@SourceID,@EnhanceID,@EnhType)
|
||||||
|
|
||||||
|
Update CC
|
||||||
|
Set Config = cast(cast(Replace(Config,'></Config','>' + SrcConfig +'</Config') as xml) as nvarchar(max))
|
||||||
|
From Contents CC
|
||||||
|
Join @EnhItems EE ON EE.SrcContentID = CC.ContentID
|
||||||
|
|
||||||
|
Update CC
|
||||||
|
Set Config = cast(cast(Replace(Config,'></Config','>' + EnhConfig +'</Config') as xml) as nvarchar(max))
|
||||||
|
From Contents CC
|
||||||
|
Join @EnhItems EE ON EE.enhContentID = CC.ContentID
|
||||||
|
|
||||||
|
SELECT [ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[LastChanged],
|
||||||
|
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
|
||||||
|
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
|
||||||
|
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
|
||||||
|
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
|
||||||
|
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
|
||||||
|
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
|
||||||
|
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
|
||||||
|
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
|
||||||
|
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
|
||||||
|
FROM [Contents] where ContentID in (Select SrcContentID from @EnhItems union Select EnhContentID from @EnhItems)
|
||||||
|
|
||||||
|
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||||
|
END TRY
|
||||||
|
BEGIN CATCH -- Catch Block
|
||||||
|
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||||
|
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||||
|
EXEC vlnErrorHandler
|
||||||
|
END CATCH
|
||||||
|
GO
|
||||||
|
-- Display the status of Proc creation
|
||||||
|
IF (@@Error = 0) PRINT 'StoredProcedure [vesp_Convert16to32EnhancedContents] Succeeded'
|
||||||
|
ELSE PRINT 'StoredProcedure [vesp_Convert16to32EnhancedContents] Error on Creation'
|
||||||
|
go
|
||||||
|
|
||||||
PRINT 'Enhanced Document Synchronization code.'
|
PRINT 'Enhanced Document Synchronization code.'
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -12680,7 +12943,7 @@ BEGIN TRY -- Try Block
|
|||||||
set nocount on
|
set nocount on
|
||||||
DECLARE @RevDate varchar(255)
|
DECLARE @RevDate varchar(255)
|
||||||
DECLARE @RevDescription varchar(255)
|
DECLARE @RevDescription varchar(255)
|
||||||
set @RevDate = '5/11/2016 9:00 AM'
|
set @RevDate = '5/12/2016 9:00 AM'
|
||||||
set @RevDescription = 'Added Enhanced Documents'
|
set @RevDescription = 'Added Enhanced Documents'
|
||||||
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
||||||
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
||||||
|
Loading…
x
Reference in New Issue
Block a user