B2012-371 Fixed the bug with inserting an outside transition – needed stored procedure vefn_ParentItems
This commit is contained in:
parent
d42972a389
commit
d02d29f0e1
@ -5340,6 +5340,61 @@ IF (@@Error = 0) PRINT 'ScalerFunction [vefn_GetItemApplicability] Succeeded'
|
||||
ELSE PRINT 'ScalerFunction [vefn_GetItemApplicability] Error on Creation'
|
||||
go
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_ParentItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_ParentItems];
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ParentItems] Script Date: 10/12/2012 16:12:01 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
select * from [dbo].[vefn_ParentItems](212)
|
||||
select * from [dbo].[vefn_ParentItems](48)
|
||||
select * from [dbo].[vefn_ParentItems](49)
|
||||
select * from [dbo].[vefn_ParentItems](50)
|
||||
select * from [dbo].[vefn_ParentItems](51)
|
||||
select * from [dbo].[vefn_ParentItems](52)
|
||||
*/
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
CREATE FUNCTION [dbo].[vefn_ParentItems](@ItemID int)
|
||||
RETURNS @Parents TABLE
|
||||
(
|
||||
ItemID int PRIMARY KEY,
|
||||
ContentID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
with Itemz([Relationship], [ItemID], [ContentID], [PreviousID]) as (
|
||||
Select 1 [Relati@Parentsonship], [ItemID], [ContentID], [PreviousID]
|
||||
FROM [Items]
|
||||
where [ItemID]=@ItemID
|
||||
Union All
|
||||
-- Parents
|
||||
select 2 [Relationship], I.[ItemID], I.[ContentID], I.[PreviousID]
|
||||
from Itemz Z
|
||||
join Parts P on P.ItemID = Z.ItemID
|
||||
join Items I on I.ContentID = P.ContentID
|
||||
-- Siblings
|
||||
Union All
|
||||
select 0 [Relationship] , I.[ItemID], I.[ContentID], I.[PreviousID]
|
||||
from Itemz Z
|
||||
join Items I on Z.PreviousID = I.ItemID
|
||||
)
|
||||
insert into @Parents select ItemID, ContentID from Itemz where Relationship > 0
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
-- Display the status of TableFunction creation
|
||||
IF (@@Error = 0) PRINT 'Function: vefn_ParentItems Succeeded'
|
||||
ELSE PRINT 'Function: vefn_ParentItems Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ve_GetItemDerivedApplicability]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [ve_GetItemDerivedApplicability];
|
||||
GO
|
||||
|
Loading…
x
Reference in New Issue
Block a user