Commit for development environment setup
This commit is contained in:
30
PROMS/SQL/ROImageBug/GetRODBsAndROFSTsAndAssociations.sql
Normal file
30
PROMS/SQL/ROImageBug/GetRODBsAndROFSTsAndAssociations.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- RODBs
|
||||
SELECT RODBID, ROName, FolderPath From RODBS
|
||||
-- ROFSTs
|
||||
Select ROFSTID, RODBID, DTS, len(ROLookup) Size, len(ROLookup)/1024 KBS from ROFSTS
|
||||
-- Associations
|
||||
Select AA.ROFSTID, RF.RODBID, DV.VersionID, FF.Name
|
||||
from associations AA
|
||||
Join ROFSTS RF ON AA.ROFSTID = RF.ROFSTID
|
||||
Join DocVersions DV ON DV.VersionID = AA.VersionID
|
||||
Join Folders FF ON Dv.FolderID = FF.FolderID
|
||||
--
|
||||
select RODBID,Count(*) HowMany from ROUSages Group by RODBID
|
||||
select RODBID,Count(*) HowMany from DROUSages Group by RODBID
|
||||
select ImageID, RODBID,FileName from ROIMAGES
|
||||
select FF.ImageID, RODBID from Figures FF Join ROImages RI ON RI.ImageID = FF.ImageID
|
||||
/*
|
||||
--Update RODBs Set FolderPath = 'C:\Plant\VEHLP\RO' where RODBID = 1
|
||||
Update Associations Set ROFSTID = 4
|
||||
delete from Figures where ROFSTID != 4
|
||||
DELETE From ROFSTS where ROFSTID != 4
|
||||
update roFSTs set RODBID = 1
|
||||
Update ROUSages set RODBID =1 where RODBID=2
|
||||
Update Contents Set Text = Replace(TEXT,' 2[END>',' 1[END>') where Text like '% 2\[END>%' escape '\'
|
||||
Update DROUSages set RODBID =1 where RODBID=2
|
||||
Update ROImages set RODBID=1 where RODBID=2 and FileName Not In (Select FileName from roimages where RODBID=1)
|
||||
Update FF Set FF.ImageID = (select ImageID from ROImages RI1 where RI1.RODBID=1 and RI.FileName = RI1.FileName)
|
||||
from Figures FF join ROIMages RI ON FF.ImageID = RI.ImageID Where RODBID = 2
|
||||
DELETE ROImages where RODBID=2
|
||||
Delete RODBs Where RODBID = 2
|
||||
*/
|
1
PROMS/SQL/ROImageBug/ROFstsSize.sql
Normal file
1
PROMS/SQL/ROImageBug/ROFstsSize.sql
Normal file
@@ -0,0 +1 @@
|
||||
select ROFSTID,RODBID,Len(ROLOOKUP) MyLength, DTS,UserID from ROFSTS
|
81
PROMS/SQL/ROImageBug/ROValues.sql
Normal file
81
PROMS/SQL/ROImageBug/ROValues.sql
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
DECLARE @TEXT nvarchar(max)
|
||||
select @TEXT = TEXT from Contents where ContentID Like 17259
|
||||
select * from vefn_SplitROs(@TEXT)
|
||||
--\v <START]\v0 11%\v #Link:ReferencedObject:2933 0003000000940000 2[END>\v0
|
||||
|
||||
SELECT ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID, RO.RODBID FROM CONTENTS
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
|
||||
SELECT ContentID --, RO.Value, RO.UsageID, RO.ROID
|
||||
FROM CONTENTS
|
||||
--CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
|
||||
|
||||
SELECT ContentID, RO.Value, RO.UsageID, RO.ROID FROM CONTENTS
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where CONTENTID = 708
|
||||
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_SplitROs](@text varchar(MAX))
|
||||
RETURNS @ROValues TABLE
|
||||
(
|
||||
Value varchar(max),
|
||||
UsageID int,
|
||||
ROID varchar(20),
|
||||
RODBID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @START nvarchar(255)
|
||||
SET @START= '\v <START]\v0 '
|
||||
DECLARE @MIDDLE nvarchar(255)
|
||||
SET @MIDDLE = '\v #Link:'
|
||||
DECLARE @MIDDLERO nvarchar(255)
|
||||
SET @MIDDLERO = '\v #Link:ReferencedObject:'
|
||||
DECLARE @END nvarchar(255)
|
||||
SET @END = '[END>\'
|
||||
DECLARE @IndexStart int
|
||||
SET @IndexStart = CHARINDEX(@START , @text)
|
||||
DECLARE @IndexEnd int
|
||||
SET @IndexEnd = CHARINDEX(@END , @text)
|
||||
WHILE (@IndexStart > 0)
|
||||
BEGIN
|
||||
DECLARE @PARTS NVARCHAR(MAX)
|
||||
DECLARE @PART1 NVARCHAR(MAX)
|
||||
DECLARE @PART2 NVARCHAR(MAX)
|
||||
DECLARE @PART3 NVARCHAR(MAX)
|
||||
SET @IndexStart = @IndexStart + len(@START) + 1
|
||||
--PRINT @IndexStart
|
||||
--PRINT @IndexEnd
|
||||
SET @PARTS = SUBSTRING(@TEXT,@IndexStart,@IndexEnd - @IndexStart)
|
||||
--PRINT @PARTS
|
||||
DECLARE @IndexMiddle int
|
||||
SET @IndexMiddle = CHARINDEX(@Middle , @PARTS)
|
||||
SET @PART1 = LEFT(@PARTS,@IndexMiddle-1)
|
||||
--PRINT @PART1
|
||||
SET @PARTS = SUBSTRING(@PARTS,@IndexMiddle, len(@PARTS))
|
||||
IF @PARTS LIKE @MIDDLERO + '%'
|
||||
BEGIN
|
||||
SET @PARTS = SUBSTRING(@PARTS,len(@MIDDLERO)+1,len(@PARTS))
|
||||
DECLARE @IndexSpace int
|
||||
SET @IndexSpace = CHARINDEX(' ',@PARTS)
|
||||
SET @PART2 = LEFT(@PARTS,@IndexSpace-1)
|
||||
--PRINT @PART2
|
||||
SET @PARTS = LTRIM(SUBSTRING(@PARTS,@IndexSpace+1,len(@PARTS)))
|
||||
SET @IndexSpace = CHARINDEX(' ',@PARTS)
|
||||
SET @PART3 = LEFT(@PARTS,@IndexSpace-1)
|
||||
--PRINT @PART3
|
||||
SET @PARTS = LTRIM(SUBSTRING(@PARTS,@IndexSpace+1,len(@PARTS)))
|
||||
--PRINT @PARTS
|
||||
Insert INTO @ROValues Values(@PART1, CAST(@PART2 AS INT), @PART3, Cast(@Parts as int))
|
||||
END
|
||||
SET @TEXT = SUBSTRING(@TEXT,@IndexEnd + LEN(@End), LEN(@TEXT))
|
||||
SET @IndexStart = CHARINDEX(@START , @text)
|
||||
SET @IndexEnd = CHARINDEX(@END , @text)
|
||||
END
|
||||
RETURN
|
||||
END
|
163
PROMS/SQL/ROImageBug/SectionStartStatus.sql
Normal file
163
PROMS/SQL/ROImageBug/SectionStartStatus.sql
Normal file
@@ -0,0 +1,163 @@
|
||||
Declare @TopSections Table
|
||||
(
|
||||
VersionID int,
|
||||
ProcID int,
|
||||
ItemID int Primary Key,
|
||||
ContentID int,
|
||||
Level int,
|
||||
FormatID int,
|
||||
Type int
|
||||
);
|
||||
with Itemz([VersionID], ProcID, [ItemID], [ContentID], [Level]) as
|
||||
(Select DV.VersionID, DV.ItemID ProcID, [I].[ItemID], [I].[ContentID], 0
|
||||
FROM [Items] I
|
||||
JOIN vefn_DocVersionSplit('') DV ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select Z.VersionID, Z.ProcID, I.[ItemID], I.[ContentID], Z.Level+1
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
join Contents C ON I.ContentID = C.contentID
|
||||
Where Type < 20000
|
||||
Union All
|
||||
-- Siblings
|
||||
select Z.VersionID, case when z.ProcID = z.ItemID then I.ItemID else Z.ProcID end ProcID, I.[ItemID], I.[ContentID], Z.Level
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
)
|
||||
insert into @TopSections
|
||||
select ZZ.VersionID, ZZ.ProcID, ZZ.[ItemID], ZZ.[ContentID], ZZ.[Level], VI.[FormatID], CC.Type
|
||||
from ItemZ ZZ
|
||||
Join vefn_GetVersionFormatItems('') VI ON ZZ.ItemID=VI.ItemID
|
||||
Join Contents CC ON ZZ.ContentID=CC.ContentID
|
||||
Where Level > 0
|
||||
OPTION (MAXRECURSION 10000)
|
||||
|
||||
DECLARE @Procedures TABLE (
|
||||
VersionID int,
|
||||
ProcID int primary key,
|
||||
PContentID int ,
|
||||
SectionStart int
|
||||
)
|
||||
Insert into @Procedures
|
||||
Select VersionID, ItemId, ContentID, xProcedure.value('@SectionStart','int') SectionStart From
|
||||
(Select VI.VersionID,VI.ItemID,VI.ContentID,Cast(Config as xml) xConfig
|
||||
from VEFN_GetVersionItems('') VI
|
||||
Join Contents CC ON CC.ContentID = VI.ContentID
|
||||
where type = 0) T1
|
||||
outer apply xConfig.nodes('//Procedure') tProcedure(xProcedure)
|
||||
|
||||
DECLARE @SectionFormats TABLE
|
||||
(
|
||||
FormatID int,
|
||||
Name nvarchar(50),
|
||||
Description nvarchar(255),
|
||||
Type int,
|
||||
IsStepSection nvarchar(10),
|
||||
SectionFormat nvarchar(255),
|
||||
NumberingSequence int
|
||||
)
|
||||
Insert Into @SectionFormats
|
||||
Select FormatID, Name, Description
|
||||
,xDocStyle.value('@Index','int')+10000 Type
|
||||
,xDocStyle.value('@IsStepSection','nvarchar(10)') IsStepSection
|
||||
,xDocStyle.value('@Name','nvarchar(255)') SectionFormat
|
||||
,xDocStyle.value('@NumberingSequence','int') NumberingSequence
|
||||
from Formats
|
||||
outer apply data.nodes('//DocStyle') tDocStyle(xDocStyle)
|
||||
where FormatID in(Select formatid from @TopSections)
|
||||
|
||||
DECLARE @OriginalSteps Table
|
||||
(
|
||||
VersionID int,
|
||||
ProcID int,
|
||||
ItemID int,
|
||||
ContentID int,
|
||||
Level int,
|
||||
FormatID int,
|
||||
Type int
|
||||
-- ,OriginalSteps char(1)
|
||||
)
|
||||
Insert Into @OriginalSteps
|
||||
Select VersionID, ProcID, ItemID, ContentID, Level, FormatID,Type
|
||||
--,isnull(xSection.value('@OriginalSteps','char(1)'),'N') OriginalSteps
|
||||
From
|
||||
(Select TS.*, cast(config as xml) xConfig From @TopSections TS
|
||||
Join Contents CC ON TS.ContentID=CC.ContentID) T1
|
||||
Outer apply xConfig.nodes('//Section') tSection(xSection)
|
||||
where isnull(xSection.value('@OriginalSteps','char(1)'),'N') ='Y'
|
||||
|
||||
--Select * from @OriginalSteps
|
||||
Declare @MultipleOriginalSteps TABLE
|
||||
(
|
||||
ProcID int primary Key,
|
||||
HowMany int
|
||||
)
|
||||
insert into @MultipleOriginalSteps
|
||||
select ProcID, Count(*) Howmany from @OriginalSteps Group by ProcID Having count(*) > 1
|
||||
|
||||
|
||||
select SectionStartStatus, OriginalStepStatus, Count(*) Howmany from (
|
||||
Select PP.*, dbo.ve_getShortPath(SectionStart) PathToSectionStart, SSTS.ItemID, SSTS.FormatID, SSSF.IsStepSection, SSTS.Level
|
||||
, isnull(OSExact.ItemID,OS.ItemID) OSItemID, MOS.ProcID MProcId,ossf.IsStepSection OSIsStepSection
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When SSTS.ItemID is null THEN 'NotSection'
|
||||
When SSTS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When SSTS.Level > 1 then 'NotTopLevel'
|
||||
When SSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end SectionStartStatus
|
||||
,case when isnull(OSExact.ItemID,OS.ItemID) is null then 'None'
|
||||
when MOS.ProcID is not null THEN 'MultipleOS'
|
||||
When OSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end OriginalStepStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections SSTS ON PP.SectionStart = SSTS.ItemID
|
||||
Left Join @SectionFormats SSSF ON SSTS.FormatID= SSSF.FormatID and SSTS.Type=SSSF.Type
|
||||
Left Join @MultipleOriginalSteps MOS ON pp.ProcID = MOS.ProcID
|
||||
Left Join @OriginalSteps OSExact ON OSExact.ProcID=pp.ProcID and OSExact.ItemID=pp.SectionStart
|
||||
Left Join (select * from @OriginalSteps Where ProcID Not In (Select Procid from @MultipleOriginalSteps)) OS ON OS.ProcID = pp.procid
|
||||
Left Join @SectionFormats OSSF ON isnull(OSExact.FormatID,OS.FormatID)= OSSF.FormatID and isnull(OSExact.Type,OS.Type)=OSSF.Type
|
||||
) T1 Group by SectionStartStatus, OriginalStepStatus
|
||||
|
||||
|
||||
Select PP.*, dbo.ve_getShortPath(SectionStart) PathToSectionStart, SSTS.ItemID, SSTS.FormatID, SSSF.IsStepSection, SSTS.Level
|
||||
, isnull(OSExact.ItemID,OS.ItemID) OSItemID, MOS.ProcID MProcId,ossf.IsStepSection OSIsStepSection
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When SSTS.ItemID is null THEN 'NotSection'
|
||||
When SSTS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When SSTS.Level > 1 then 'NotTopLevel'
|
||||
When SSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end SectionStartStatus
|
||||
,case when isnull(OSExact.ItemID,OS.ItemID) is null then 'None'
|
||||
when MOS.ProcID is not null THEN 'MultipleOS'
|
||||
When OSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end OriginalStepStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections SSTS ON PP.SectionStart = SSTS.ItemID
|
||||
Left Join @SectionFormats SSSF ON SSTS.FormatID= SSSF.FormatID and SSTS.Type=SSSF.Type
|
||||
Left Join @MultipleOriginalSteps MOS ON pp.ProcID = MOS.ProcID
|
||||
Left Join @OriginalSteps OSExact ON OSExact.ProcID=pp.ProcID and OSExact.ItemID=pp.SectionStart
|
||||
Left Join (select * from @OriginalSteps Where ProcID Not In (Select Procid from @MultipleOriginalSteps)) OS ON OS.ProcID = pp.procid
|
||||
Left Join @SectionFormats OSSF ON isnull(OSExact.FormatID,OS.FormatID)= OSSF.FormatID and isnull(OSExact.Type,OS.Type)=OSSF.Type
|
||||
|
||||
|
||||
/*
|
||||
Select VersionID,GrandParentName,ParentName,FolderName,[Good],[None],[NotInProc],[NotSection],[NotTopLevel]
|
||||
FROM (Select VN.*, PP.ProcID
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When TS.ItemID is null THEN 'NotSection'
|
||||
When TS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When Level > 1 then 'NotTopLevel'
|
||||
else 'Good' end SectionStartStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections TS ON PP.SectionStart = TS.ItemID
|
||||
Join VEFN_GetVersionNames() VN ON VN.VersionID = PP.VersionID) P1
|
||||
PIVOT(COUNT(ProcID) FOR SectionStartStatus IN ( [Good],[None],[NotInProc],[NotSection],[NotTopLevel]))
|
||||
AS P2
|
||||
Order By VersionID
|
||||
*/
|
7
PROMS/SQL/ROImageBug/VersionAssocaitions.sql
Normal file
7
PROMS/SQL/ROImageBug/VersionAssocaitions.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
SELECT DV.VersionID, FF.NAme, ASSOCIATIONID, AA.ROFSTID, RODBID
|
||||
from DocVersions DV
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
|
||||
Update Associations set ROFSTID = 4 where AssociationID = 3
|
18
PROMS/SQL/ROImageBug/VersionRODBIDsDetail.sql
Normal file
18
PROMS/SQL/ROImageBug/VersionRODBIDsDetail.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
SELECT VI.VersionID,
|
||||
FF.Name, RF.RODBID VersionDBID
|
||||
, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
|
||||
, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
|
||||
, RO.RODBID TextRODBID, RD.RONAME
|
||||
--, Count(*) HowMany
|
||||
FROM CONTENTS CC
|
||||
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
JOIN RODBS RD ON RD.RODBID = RF.RODBID
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
--Group By
|
||||
--VI.VersionID,
|
||||
--FF.Name, RF.RODBID , RO.RODBID, RD.ROName
|
18
PROMS/SQL/ROImageBug/VersionRODBIDsSummary.sql
Normal file
18
PROMS/SQL/ROImageBug/VersionRODBIDsSummary.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
SELECT --VI.VersionID,
|
||||
FF.Name, RF.RODBID VersionDBID
|
||||
--, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
|
||||
--, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
|
||||
, RO.RODBID TextRODBID, RD.RONAME
|
||||
, Count(*) HowMany
|
||||
FROM CONTENTS CC
|
||||
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
JOIN RODBS RD ON RD.RODBID = RF.RODBID
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
Group By
|
||||
--VI.VersionID,
|
||||
FF.Name, RF.RODBID , RO.RODBID, RD.ROName
|
Reference in New Issue
Block a user