Added Unit Number info to the search stored procedures

This commit is contained in:
John Jenko 2011-09-22 19:59:18 +00:00
parent c5dc03ee1c
commit 47804ed7ff

View File

@ -15280,7 +15280,7 @@ select * from vefn_SiblingAndChildrenItems('3') II
join
*/
CREATE FUNCTION [dbo].[vefn_SiblingAndChildrenItems](@DocVersionList varchar(10))
CREATE FUNCTION [dbo].[vefn_SiblingAndChildrenItems](@DocVersionList varchar(10),@UnitPrefix varchar(MAX))
RETURNS @SiblingAndChildren TABLE
(
[ItemID] int PRIMARY KEY
@ -15318,7 +15318,7 @@ with Itemz([ItemID], [DVPath], [Level], [ParentID], [Ordinal], [PreviousID], [Fr
Select [I].[ItemID], DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID]
,0 [pContentID],[I].[DTS] [pDTS], [I].[UserID] [pUserID],
Cast('' as nvarchar(max)) [PPath],
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) [Path],
Cast(Case when C.Type < 20000 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) [Path],
0 IsRNO, Cast('' as nvarchar(max)) [POrdinalPath], Cast('0001' as nvarchar(max)) [OrdinalPath]
FROM [Items] I
Join Contents C on C.ContentID=I.ContentID
@ -15338,8 +15338,8 @@ Union All
else '' end
PPath,
Path + case C.Type/10000
when 0 then @Delim +C.Number + @DelimNumber + C.Text
when 1 then @Delim +C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else
case P.FromType
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
@ -15364,8 +15364,8 @@ Union All
PPath,
--'1' +
PPath + case C.Type/10000
when 0 then @Delim + C.Number + @DelimNumber + C.Text
when 1 then @Delim + C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
end Path, 0,
POrdinalPath,
@ -16453,14 +16453,14 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_SearchAnnot
GO
/*
exec vesp_SearchAnnotationItemAndChildren Null,Null,'1',Null,0
exec vesp_SearchAnnotationItemAndChildren Null,Null,'1',Null,0,"3-"
exec vesp_SearchAnnotationItemAndChildren Null,Null,'2',Null,0
exec vesp_SearchAnnotationItemAndChildren Null,Null,'3',Null,0
exec vesp_SearchAnnotationItemAndChildren Null,Null,'4',Null,0
exec vesp_SearchAnnotationItemAndChildren Null,Null,'5',Null,0
exec vesp_SearchAnnotationItemAndChildren Null,Null,'',Null,0
*/
CREATE PROCEDURE [dbo].[vesp_SearchAnnotationItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX), @AnnotationTypeList varchar(MAX), @SearchString nvarchar(MAX), @CaseSensitive as int)
CREATE PROCEDURE [dbo].[vesp_SearchAnnotationItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX), @AnnotationTypeList varchar(MAX), @SearchString nvarchar(MAX), @CaseSensitive as int, @UnitPrefix nvarchar(MAX))
WITH EXECUTE AS OWNER
AS
BEGIN
@ -16477,7 +16477,7 @@ with Itemz(DVPath, [Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [From
Select DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [I].[ItemID], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID],[I].[LastChanged]
,0 [pContentID],[I].[DTS] [pDTS], [I].[UserID] [pUserID], [I].[LastChanged] [pLastChanged],
Cast('' as nvarchar(max)) PPath,
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
Cast(Case when C.Type < 20000 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
0 IsRNO, Cast('' as nvarchar(max)) POrdinalPath, Cast('0001' as nvarchar(max)) OrdinalPath
FROM [Items] I
Join Contents C on C.ContentID=I.ContentID
@ -16497,8 +16497,8 @@ Union All
else '' end
PPath,
Path + case C.Type/10000
when 0 then @Delim +C.Number + @DelimNumber + C.Text
when 1 then @Delim +C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else
case P.FromType
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
@ -16523,8 +16523,8 @@ Union All
,PPath,
--'1' +
PPath + case C.Type/10000
when 0 then @Delim + C.Number + @DelimNumber + C.Text
when 1 then @Delim + C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
end Path, 0,
POrdinalPath,
@ -16608,7 +16608,7 @@ exec vesp_SearchItemAndChildren '','','CHECK NORMAL',0,0,0,0
exec vesp_SearchItemAndChildren '','','turbine-driven',0,0,0,0
*/
CREATE PROCEDURE [dbo].[vesp_SearchItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX),
@SearchString varchar(MAX), @CaseSensitive as int, @IncludeLinks as int, @IncludeRtfFormatting as int, @IncludeSpecialCharacters as int)
@SearchString varchar(MAX), @CaseSensitive as int, @IncludeLinks as int, @IncludeRtfFormatting as int, @IncludeSpecialCharacters as int, @UnitPrefix as varchar(MAX))
WITH EXECUTE AS OWNER
AS
BEGIN
@ -16625,7 +16625,7 @@ with Itemz(DVPath, [Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [From
Select DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [I].[ItemID], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID],[I].[LastChanged]
,0 [pContentID],[I].[DTS] [pDTS], [I].[UserID] [pUserID], [I].[LastChanged] [pLastChanged],
Cast('' as nvarchar(max)) PPath,
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
Cast(Case when C.Type < 20000 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
0 IsRNO, Cast('' as nvarchar(max)) POrdinalPath, Cast('0001' as nvarchar(max)) OrdinalPath
FROM [Items] I
Join Contents C on C.ContentID=I.ContentID
@ -16645,8 +16645,8 @@ Union All
else '' end
PPath,
Path + case C.Type/10000
when 0 then @Delim +C.Number + @DelimNumber + C.Text
when 1 then @Delim +C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else
case P.FromType
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
@ -16671,8 +16671,8 @@ Union All
,PPath,
--'1' +
PPath + case C.Type/10000
when 0 then @Delim + C.Number + @DelimNumber + C.Text
when 1 then @Delim + C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
end Path, 0,
POrdinalPath,
@ -16760,7 +16760,7 @@ exec vesp_SearchItemAndChildrenNew '','','%turbine-driven%',0,0,0,0
*/
CREATE PROCEDURE [dbo].[vesp_SearchItemAndChildrenNew] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX),
@SearchString varchar(MAX), @CaseSensitive as int, @IncludeLinks as int, @IncludeRtfFormatting as int, @IncludeSpecialCharacters as int)
@SearchString varchar(MAX), @CaseSensitive as int, @IncludeLinks as int, @IncludeRtfFormatting as int, @IncludeSpecialCharacters as int, @UnitPrefix as varchar(MAX))
WITH EXECUTE AS OWNER
AS
select ZZ.DvPath, ZZ.Path, ZZ.[Level],ZZ.[FromType],ZZ.[Ordinal], ZZ.[ParentID], ZZ.[ItemID],ZZ.[PreviousID],ZZ.[ContentID],ZZ.[DTS],ZZ.[UserID]
@ -16783,7 +16783,7 @@ select ZZ.DvPath, ZZ.Path, ZZ.[Level],ZZ.[FromType],ZZ.[Ordinal], ZZ.[ParentID],
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=CC.[ContentID]) [RoUsageCount],
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=CC.[ContentID]) [TransitionCount],
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=CC.[ContentID]) [ZContentCount]
from vefn_SiblingAndChildrenItems(@DocVersionList) ZZ
from vefn_SiblingAndChildrenItems(@DocVersionList, @UnitPrefix) ZZ
Join Items II on ZZ.ItemID=II.ItemID
Left Join Parts PP on ZZ.PContentID=PP.ContentID and ZZ.FromType = PP.FromType
Join Contents CC on CC.ContentID=ZZ.ContentID
@ -16808,7 +16808,7 @@ exec vesp_SearchROItemAndChildren '1,2,4','20006','1'
exec vesp_SearchROItemAndChildren '1,2,4','20006',''
exec vesp_SearchROItemAndChildren '1,2,4',Null,Null
*/
CREATE PROCEDURE [dbo].[vesp_SearchROItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX), @ROSearchString varchar(MAX))
CREATE PROCEDURE [dbo].[vesp_SearchROItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX), @ROSearchString varchar(MAX), @UnitPrefix as varchar(MAX))
WITH EXECUTE AS OWNER
AS
BEGIN
@ -16824,7 +16824,7 @@ with Itemz(DVPath, [Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [From
Select DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [I].[ItemID], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID],[I].[LastChanged]
,0 [pContentID],[I].[DTS] [pDTS], [I].[UserID] [pUserID], [I].[LastChanged] [pLastChanged],
Cast('' as nvarchar(max)) PPath,
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
Cast(Case when C.Type < 20000 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
0 IsRNO, Cast('' as nvarchar(max)) POrdinalPath, Cast('0001' as nvarchar(max)) OrdinalPath
FROM [Items] I
@ -16846,8 +16846,8 @@ Union All
PPath,
--Path + case when Z.FromType < 3 then @Delim else @DelimStep end + case C.Type/10000
Path + case C.Type/10000
when 0 then @Delim +C.Number + @DelimNumber + C.Text
when 1 then @Delim +C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else
case P.FromType
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
@ -16872,8 +16872,8 @@ Union All
,PPath,
--'1' +
PPath + case C.Type/10000
when 0 then @Delim + C.Number + @DelimNumber + C.Text
when 1 then @Delim + C.Number + @DelimNumber + C.Text
when 0 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
when 1 then @Delim + @UnitPrefix + C.Number + @DelimNumber + C.Text
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
end Path, 0,
POrdinalPath,