B2022-083: Support Conditional RO Values (v2.1) [Part-2]
This commit is contained in:
@@ -20041,15 +20041,909 @@ GO
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
End: B2022-026 RO Memory reduction coding (Jakes Merge) [Version 2.0]
|
||||
==========================================================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
Start: B2022-083: Support Conditional RO Values (v2.1)
|
||||
==========================================================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------------------
|
||||
Tables:
|
||||
----------------------------------------------------------------------------------
|
||||
[RofstExtension] [Created]
|
||||
*/
|
||||
|
||||
-- If RofstExtension table already exists then don't drop and recreate it
|
||||
IF Not Exists(SELECT * FROM sys.objects Where name = 'RofstExtension' AND type in (N'U'))
|
||||
Begin
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
|
||||
CREATE TABLE [dbo].[RofstExtension](
|
||||
[Offset] [int] NOT NULL,
|
||||
[RoidExt] [varchar](4) NOT NULL,
|
||||
[AccPageExt] [varchar](5) NOT NULL,
|
||||
CONSTRAINT [PK_RofstExtension] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Offset] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF (@@Error = 0) PRINT 'Table Creation: [RofstExtension] Succeeded'
|
||||
ELSE PRINT 'Table Creation: [RofstExtension] Error on Creation'
|
||||
|
||||
IF (@@Error = 0)
|
||||
Begin
|
||||
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (1,'0041','A');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (2,'0042','B');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (3,'0043','C');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (4,'0044','D');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (5,'0045','E');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (6,'0046','F');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (7,'0047','G');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (8,'0048','H');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (9,'0049','I');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (10,'004A','J');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (11,'004B','K');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (12,'004C','L');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (13,'004D','M');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (14,'004E','N');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (15,'004F','O');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (16,'0050','P');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (17,'0051','Q');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (18,'0052','R');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (19,'0053','S');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (20,'0054','T');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (21,'0055','U');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (22,'0056','V');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (23,'0057','W');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (24,'0058','X');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (25,'0059','Y');
|
||||
Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (26,'005A','Z');
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
Go
|
||||
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------------------
|
||||
Functions:
|
||||
----------------------------------------------------------------------------------
|
||||
[dbo].[vefn_RofstDataCleanUnitInfoTags] [Created]
|
||||
[dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] [Created]
|
||||
[dbo].[vefn_RofstDataReplaceVars] [Modified]
|
||||
*/
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataCleanUnitInfoTags] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataCleanUnitInfoTags' AND type in (N'FN'))
|
||||
DROP FUNCTION [dbo].[vefn_RofstDataCleanUnitInfoTags]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- ==========================================================================================
|
||||
-- Author: Jake Ropar
|
||||
-- Create Date: 06/21/2022
|
||||
-- Description: Removes any legacy legacy unit info variables and fixes older applicability tags
|
||||
-- ==========================================================================================
|
||||
|
||||
CREATE FUNCTION [dbo].[vefn_RofstDataCleanUnitInfoTags](@Values VarChar(Max), @RemoveUnitInfoVars bit = 0) Returns VarChar(Max)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
Declare @RetVal VarChar(Max) = '';
|
||||
|
||||
Set @RetVal = dbo.vefn_Clean(@Values, 1, null);
|
||||
|
||||
If (Len(@RetVal) > 0)
|
||||
Begin
|
||||
|
||||
-- Make Sure all tag/var instances are upper case & Remove any internal spaces
|
||||
Set @RetVal = Replace(@RetVal, 'U-OTHER TEXT', 'U-OTHERTEXT');
|
||||
Set @RetVal = Replace(@RetVal, 'U-OTHER NUMBER', 'U-OTHERNUMBER');
|
||||
Set @RetVal = Replace(@RetVal, 'U-OTHER NAME', 'U-OTHERNAME');
|
||||
Set @RetVal = Replace(@RetVal, 'U-OTHER ID', 'U-OTHERID');
|
||||
Set @RetVal = Replace(@RetVal, '<u>', '<U-ID>');
|
||||
|
||||
If (@RemoveUnitInfoVars > 0)
|
||||
Begin
|
||||
|
||||
-- Remove any Unit Info Variables
|
||||
Set @RetVal = Replace(@RetVal, '<u>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-ID>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-NUMBER>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-NAME>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-TEXT>', '');
|
||||
|
||||
Set @RetVal = Replace(@RetVal, '<U-OTHERID>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-OTHERNUMBER>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-OTHERNAME>', '');
|
||||
Set @RetVal = Replace(@RetVal, '<U-OTHERTEXT>', '');
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Return @RetVal;
|
||||
|
||||
END
|
||||
Go
|
||||
|
||||
IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Succeeded'
|
||||
ELSE PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceLegacyTagsWithDefaults' AND type in (N'FN'))
|
||||
DROP FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- ==========================================================================================
|
||||
-- Author: Jake Ropar
|
||||
-- Create Date: 06/21/2022
|
||||
-- Description: Replaces any legacy applicability tags with the default value
|
||||
-- ==========================================================================================
|
||||
|
||||
CREATE FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
Declare @RetVal VarChar(Max) = '';
|
||||
Declare @DefaultValue VarChar(Max) = '';
|
||||
|
||||
Declare @StartTagIndex Int;
|
||||
Declare @EndTagIndex Int;
|
||||
Declare @StartTagValue VarChar(Max);
|
||||
Declare @StartValIndex Int;
|
||||
Declare @EndValIndex Int;
|
||||
|
||||
Declare @TagName VarChar(Max);
|
||||
Declare @LegacyTagNames VarChar(Max) = 'U-ID,U-NUMBER,U-NAME,U-TEXT,U-OTHERID,U-OTHERNUMBER,U-OTHERNAME,U-OTHERTEXT';
|
||||
|
||||
-- Make Sure all tag instances are upper case & Remove any internal spaces
|
||||
Set @RetVal = dbo.vefn_RofstDataCleanUnitInfoTags(@Values, 0);
|
||||
|
||||
|
||||
Declare LegacyTags_Cursor Cursor Fast_Forward For
|
||||
Select '{' + x.ListValue + '{' as 'TagName'
|
||||
From [dbo].[vefn_ParseStringListToTable](@LegacyTagNames, ',') x
|
||||
|
||||
Open LegacyTags_Cursor
|
||||
|
||||
Fetch Next From LegacyTags_Cursor Into @TagName
|
||||
|
||||
While (@@FETCH_STATUS = 0)
|
||||
Begin
|
||||
|
||||
-- Get Start/End Index of Tag
|
||||
Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal);
|
||||
Set @EndTagIndex = PatIndex('%}}%', @RetVal);
|
||||
|
||||
While (@StartTagIndex > 0)
|
||||
Begin
|
||||
|
||||
Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 2);
|
||||
|
||||
Set @StartValIndex = PatIndex('%=%', @StartTagValue);
|
||||
Set @EndValIndex = PatIndex('%}%', @StartTagValue);
|
||||
|
||||
Set @DefaultValue = SubString(@StartTagValue, @StartValIndex + 1, (@EndValIndex - @StartValIndex) - 1);
|
||||
Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue);
|
||||
|
||||
Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal);
|
||||
Set @EndTagIndex = PatIndex('%}}%', @RetVal);
|
||||
|
||||
End -- While (@StartTagIndex > 0)
|
||||
|
||||
|
||||
Fetch Next From LegacyTags_Cursor Into @TagName
|
||||
End
|
||||
|
||||
Close LegacyTags_Cursor;
|
||||
Deallocate LegacyTags_Cursor;
|
||||
|
||||
|
||||
Return @RetVal;
|
||||
|
||||
END
|
||||
Go
|
||||
|
||||
IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Succeeded'
|
||||
ELSE PRINT 'Function Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceVars' AND type in (N'FN'))
|
||||
DROP FUNCTION [dbo].[vefn_RofstDataReplaceVars]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- ==========================================================================================
|
||||
-- Author: Jake Ropar
|
||||
-- Create Date: 3/25/2022
|
||||
-- Description: Replaces Any Variables and returns the rest of the value string
|
||||
-- ==========================================================================================
|
||||
|
||||
CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
Declare @RetVal VarChar(Max) = '';
|
||||
Declare @EqualsIndex Int;
|
||||
Declare @EndIndex Int;
|
||||
Declare @NameValPairStartIndex Int;
|
||||
Declare @NameValPairEndIndex Int;
|
||||
|
||||
Declare @VarPair VarChar(Max);
|
||||
Declare @VarName VarChar(Max);
|
||||
Declare @VarValue VarChar(Max);
|
||||
|
||||
-- Replace Any "<APL /APL>" Tags with the Default Value first
|
||||
Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values);
|
||||
|
||||
-- Replace Any Legacy Applicability Tags with the Default Value second
|
||||
Select @RetVal = dbo.vefn_RofstDataReplaceLegacyTagsWithDefaults(@RetVal);
|
||||
|
||||
|
||||
If (PatIndex('%{{A%', @RetVal) > 0)
|
||||
Set @EndIndex = PatIndex('%{{A%', @RetVal);
|
||||
Else
|
||||
Set @EndIndex = Len(@RetVal) -1;
|
||||
|
||||
Set @NameValPairStartIndex = PatIndex('%{%', @RetVal);
|
||||
Set @NameValPairEndIndex = PatIndex('%}%', @RetVal);
|
||||
|
||||
While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex)
|
||||
Begin
|
||||
|
||||
-- Get Name Value Pair [ex. {EGS=1214}]
|
||||
Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1);
|
||||
|
||||
-- Remove Name Value Pair From Return Val
|
||||
Set @RetVal = Replace(@RetVal, @VarPair, '');
|
||||
|
||||
-- Get Variable Name and Value
|
||||
Set @EqualsIndex = PatIndex('%=%', @VarPair);
|
||||
|
||||
If (@EqualsIndex > 0)
|
||||
Begin
|
||||
Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2);
|
||||
Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1);
|
||||
Set @VarName = Concat('{', @VarName, '}');
|
||||
|
||||
-- Replace All Occurences
|
||||
Set @RetVal = Replace(@RetVal, @VarName, @VarValue);
|
||||
End
|
||||
|
||||
-- Get Updated Index Values
|
||||
If (PatIndex('%{{A%', @RetVal) > 0)
|
||||
Set @EndIndex = PatIndex('%{{A%', @RetVal);
|
||||
Else
|
||||
Set @EndIndex = Len(@RetVal) -1;
|
||||
|
||||
Set @NameValPairStartIndex = PatIndex('%{%', @RetVal);
|
||||
Set @NameValPairEndIndex = PatIndex('%}%', @RetVal);
|
||||
|
||||
End -- End While(@ReplaceVarEndTagIndex > 0)
|
||||
|
||||
Return @RetVal;
|
||||
|
||||
END
|
||||
Go
|
||||
|
||||
IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataReplaceVars] Succeeded'
|
||||
ELSE PRINT 'Function Creation: [vefn_RofstDataReplaceVars] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------------------
|
||||
Views:
|
||||
----------------------------------------------------------------------------------
|
||||
[dbo].[vwRofstData_RofstExtensions] [Created]
|
||||
[dbo].[vwRofstData_RofstValueTypes] [Created]
|
||||
[dbo].[vwRofstData_RofstBaseRoids] [Created]
|
||||
[dbo].[vwRofstData_RofstChildren] [Modified]
|
||||
*/
|
||||
|
||||
/****** Object: View [dbo].[vwRofstData_RofstExtensions] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstExtensions' AND type in (N'V'))
|
||||
DROP VIEW [dbo].[vwRofstData_RofstExtensions]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 06/21/2024
|
||||
Description: (RofstData) Master View for RofstExtensions
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstExtensions]
|
||||
As
|
||||
|
||||
Select re.Offset as 'Offset',
|
||||
re.RoidExt as 'RoidExt',
|
||||
re.AccPageExt as 'AccPageExt'
|
||||
From RofstExtension re With (NoLock)
|
||||
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstExtensions] Succeeded'
|
||||
ELSE PRINT 'View Creation: [vwRofstData_RofstExtensions] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/****** Object: View [dbo].[vwRofstData_RofstValueTypes] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstValueTypes' AND type in (N'V'))
|
||||
DROP VIEW [dbo].[vwRofstData_RofstValueTypes]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 06/21/2022
|
||||
Description: (RofstData) Master View for Rofst Value Types
|
||||
(0) Unknown (1) Single Line Text (2) Table (3) Multiple Line Text (4) X/Y Plot (8) Image
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstValueTypes]
|
||||
As
|
||||
|
||||
Select '0' as 'TypeID', 'Unknown' as 'TypeDescription'
|
||||
|
||||
Union All
|
||||
|
||||
Select '1' as 'TypeID', 'Single Line Text' as 'TypeDescription' -- Fixed Length Text
|
||||
|
||||
Union All
|
||||
|
||||
Select '2' as 'TypeID', 'Table' as 'TypeDescription'
|
||||
|
||||
Union All
|
||||
|
||||
Select '3' as 'TypeID', 'Multiple Line Text' as 'TypeDescription'
|
||||
|
||||
Union All
|
||||
|
||||
Select '4' as 'TypeID', 'X/Y Plot' as 'TypeDescription'
|
||||
|
||||
Union All
|
||||
|
||||
Select '8' as 'TypeID', 'Image' as 'TypeDescription'
|
||||
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstValueTypes] Succeeded'
|
||||
ELSE PRINT 'View Creation: [vwRofstData_RofstValueTypes] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/****** Object: View [dbo].[vwRofstData_RofstBaseRoids] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstBaseRoids' AND type in (N'V'))
|
||||
DROP VIEW [dbo].[vwRofstData_RofstBaseRoids]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2024
|
||||
Description: (RofstData) Master View for Rofst Base Roid / AccPageID Values
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstBaseRoids]
|
||||
As
|
||||
|
||||
Select RofstID as 'RofstID',
|
||||
Left(roid, 12) as 'BaseRoid',
|
||||
Left(AccPageID, (Len(AccPageID)-2)) as 'BaseAccPageID'
|
||||
From vwRofstData_RofstDefaultValues
|
||||
Where AccPageID like '%.A';
|
||||
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstBaseRoids] Succeeded'
|
||||
ELSE PRINT 'View Creation: [vwRofstData_RofstBaseRoids] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: View [dbo].[vwRofstData_RofstChildren] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstChildren' AND type in (N'V'))
|
||||
DROP VIEW [dbo].[vwRofstData_RofstChildren]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2024
|
||||
Description: (RofstData) Master View for RofstChildren (RoChild & Groups)
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstChildren]
|
||||
As
|
||||
|
||||
Select rc.RofstChildID as 'RofstChildID',
|
||||
rd.RofstID as 'RofstID',
|
||||
-- RoDatabase Info
|
||||
rd.dbiID as 'dbiID',
|
||||
rd.dbiType as 'dbiType',
|
||||
rd.dbiAW as 'dbiAW',
|
||||
rd.dbiTitle as 'dbiTitle',
|
||||
rd.dbiAP as 'dbiAP',
|
||||
-- RoChild Info
|
||||
rc.ID as 'ID',
|
||||
rc.ParentID as 'ParentID',
|
||||
rc.[type] as 'type',
|
||||
IsNull(vt.TypeDescription, 'Unknown') as 'TypeDescription',
|
||||
rc.title as 'title',
|
||||
rc.roid as 'roid',
|
||||
rc.appid as 'appid',
|
||||
rc.[value] as 'value',
|
||||
Case When (Not rc.[value] is null) Then rd.dbiAP + '-' + rc.appid Else null End as 'AccPageID'
|
||||
From RofstChild rc With (NoLock)
|
||||
inner join RofstDatabase rd With (NoLock) on rc.RofstID = rd.RofstID and rc.dbiID = rd.dbiID
|
||||
left outer join vwRofstData_RofstValueTypes vt on vt.TypeID = rc.[type];
|
||||
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstChildren] Succeeded'
|
||||
ELSE PRINT 'View Creation: [vwRofstData_RofstChildren] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------------------
|
||||
Stored Procs:
|
||||
----------------------------------------------------------------------------------
|
||||
[dbo].[vesp_RofstDataGetChildByID] [Deleted]
|
||||
[dbo].[vesp_RofstDataGetExtensions] [Created]
|
||||
[dbo].[vesp_RofstChildInsert] [Modified]
|
||||
[dbo].[vesp_RofstDataSearch] [Modified]
|
||||
[dbo].[vesp_RofstDataGetChildByAccPageID] [Modified]
|
||||
[dbo].[vesp_RofstDataGetChildByRoid] [Modified]
|
||||
*/
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByID' AND type in (N'P'))
|
||||
DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByID]
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Deletion: [vesp_RofstDataGetChildByID] Succeeded'
|
||||
ELSE PRINT 'Procedure Deletion: [vesp_RofstDataGetChildByID] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetExtensions] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetExtensions' AND type in (N'P'))
|
||||
DROP PROCEDURE [dbo].[vesp_RofstDataGetExtensions]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 06/21/2022
|
||||
Description: Gets the Ro Lookup Extensions
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetExtensions]
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select re.Offset,
|
||||
re.RoidExt,
|
||||
re.AccPageExt
|
||||
From vwRofstData_RofstExtensions re
|
||||
Order By re.Offset Asc;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetExtensions] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetExtensions] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstChildInsert' AND type in (N'P'))
|
||||
DROP PROCEDURE [dbo].[vesp_RofstChildInsert]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstChildInsert]
|
||||
(
|
||||
@RofstID Int,
|
||||
@ID Int,
|
||||
@ParentID Int,
|
||||
@dbiID Int,
|
||||
@type Int,
|
||||
@title VarChar(Max),
|
||||
@roid VarChar(50),
|
||||
@appid VarChar(Max) = null,
|
||||
@value VarChar(Max) = null
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Declare @BaseAccPageID VarChar(Max) = null;
|
||||
Declare @DefaultValues VarChar(Max);
|
||||
|
||||
|
||||
-- Create Rofst Child/Group Record --> [Roid = (12) Digits]
|
||||
Insert Into RofstChild (RofstID, ID, ParentID, dbiID, [type], title, roid, appid, [value])
|
||||
Values (@RofstID, @ID, @ParentID, @dbiID, @type, @title, @roid, @appid, @value);
|
||||
|
||||
|
||||
-- Check for appid, if exists, then insert the default value for each return type if multi-value
|
||||
If (Len(@appid) > 0)
|
||||
Begin
|
||||
|
||||
-- Get Accessory Page ID
|
||||
Select @BaseAccPageID = dbo.vefn_RofstDataCleanUnitInfoTags(Concat(d.dbiAP, '-', @appid), 1)
|
||||
From RofstDatabase d with (NoLock)
|
||||
Where d.RofstID = @RofstID And d.dbiID = @dbiID;
|
||||
|
||||
-- Insert Rofst Default Value(s) (Children RoChild) --> [Roid = (16) Digits]
|
||||
Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', '');
|
||||
|
||||
With ChildrenValues as
|
||||
(
|
||||
Select x.ListPosition as 'OffsetIndex',
|
||||
Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue'
|
||||
From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x
|
||||
Where Len(x.ListValue) > 0
|
||||
)
|
||||
Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID)
|
||||
Select @RofstID as 'RofstID',
|
||||
Concat(@roid, re.RoidExt) as 'roid',
|
||||
Case When (Len(RTrim(LTrim(cv.DefaultValue))) > 0 ) Then dbo.vefn_RofstDataCleanUnitInfoTags(cv.DefaultValue, 0) Else '[TBD]' End as 'value',
|
||||
Concat(@BaseAccPageID, '.', re.AccPageExt) as 'AccPageID'
|
||||
From ChildrenValues cv
|
||||
inner join vwRofstData_RofstExtensions re on re.Offset = cv.OffsetIndex
|
||||
Order By cv.OffsetIndex Asc
|
||||
|
||||
|
||||
End -- (Len(@appid) > 0)
|
||||
|
||||
|
||||
Return;
|
||||
|
||||
End
|
||||
Go
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstChildInsert] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_RofstChildInsert] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataSearch' AND type in (N'P'))
|
||||
DROP PROCEDURE [dbo].[vesp_RofstDataSearch]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description: RO Default Value Search
|
||||
|
||||
@SearchTypeID => (1) Starts With (2) Ends With (3) Contains (4) Exact Match
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataSearch]
|
||||
(
|
||||
@RofstID int,
|
||||
@Value VarChar(Max) = null,
|
||||
@SearchTypeID Int = 1, -- Starts With
|
||||
@OnlyRoid16 Bit = 1, -- Return Only Roid16 Records
|
||||
@MaxNumOfRecords Int = null
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
-- Remove any leading/trailing white spaces
|
||||
Set @Value = dbo.vefn_Clean( @Value, 0, null );
|
||||
|
||||
-- Escape any % signs in the search value
|
||||
Set @Value = Replace( @Value, '%', '[%]' );
|
||||
|
||||
-- Format search value
|
||||
If (Len(@Value) = 0) Set @Value = null;
|
||||
|
||||
-- Create Temp Results Table
|
||||
Create Table #SearchResults (roid VarChar(50) Not Null, [value] VarChar(Max), RowNum Int Not Null Primary Key);
|
||||
|
||||
-- Select roids/values based on search criteria
|
||||
Insert Into #SearchResults (roid, [value], RowNum)
|
||||
Select rdv.roid,
|
||||
rdv.[value],
|
||||
Row_Number() Over (Order By rdv.[value] Asc, rdv.roid Asc) as 'RowNum'
|
||||
From vwRofstData_RofstDefaultValues rdv
|
||||
Where rdv.RofstID = @RofstID
|
||||
And (@OnlyRoid16 = 0 Or Len(rdv.roid) = 16)
|
||||
And ((@Value is null)
|
||||
Or (@SearchTypeID = 1 And rdv.[value] like @Value + '%') -- Starts With
|
||||
Or (@SearchTypeID = 2 And rdv.[value] like '%' + @Value) -- Ends With
|
||||
Or (@SearchTypeID = 3 And rdv.[value] like '%' + @Value + '%') -- Contains
|
||||
Or (@SearchTypeID = 4 And rdv.[value] = @Value)) -- Exact Match
|
||||
Order By rdv.[value] Asc, rdv.roid Asc
|
||||
Option (Recompile);
|
||||
|
||||
-- Return the specified number of results
|
||||
Select sr.roid, sr.[value]
|
||||
From #SearchResults sr
|
||||
Where (@MaxNumOfRecords is null Or sr.RowNum <= @MaxNumOfRecords)
|
||||
Order By sr.RowNum Asc;
|
||||
|
||||
Return;
|
||||
End
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataSearch] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_RofstDataSearch] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByAccPageID' AND type in (N'P'))
|
||||
DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByAccPageID]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description: Check if the AccPageID passed in has a specific Return Value Type Extension (.A, .B, .C, etc.)
|
||||
If so, then strip off the return value specific extension to get the BaseAccPageID for the lookup.
|
||||
Use the BaseAccPageID to lookup the BaseRoid, then use the Roid to lookup the Ro Child Object
|
||||
|
||||
Note** Using the AccPageID to first lookup the roid, then using the roid to lookup the data is
|
||||
significantly faster than directly looking up the data using the AccPageID because of the indexes
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildByAccPageID]
|
||||
(
|
||||
@RofstID int,
|
||||
@AccPageID VarChar(50)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Declare @BaseAccPageID VarChar(Max);
|
||||
Declare @Roid VarChar(Max);
|
||||
|
||||
If (PatIndex('%.[A-Z]', @AccPageID) > 0)
|
||||
Set @BaseAccPageID = Left(@AccPageID, Len(@AccPageID)-2);
|
||||
Else
|
||||
Set @BaseAccPageID = @AccPageID;
|
||||
|
||||
-- First use the AccPageID to get the BaseRoid
|
||||
Select @Roid = rb.BaseRoid
|
||||
From vwRofstData_RofstBaseRoids rb
|
||||
Where rb.RofstID = @RofstID
|
||||
And rb.BaseAccPageID = @BaseAccPageID;
|
||||
|
||||
-- Then use the Roid to lookup the Ro Child Object
|
||||
Select rc.ROFstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Where rc.RofstID = @RofstID
|
||||
And rc.roid = @Roid;
|
||||
|
||||
Return;
|
||||
End
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByRoid' AND type in (N'P'))
|
||||
DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByRoid]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description: The data in the Rofst Children table currently only goes down to the (12) digit roid level.
|
||||
To look up a specific return type value (16) digit roid for a RO object, you first have to
|
||||
load the base RO object by its (12) digit roid in code, and then look for the specific
|
||||
return value in the RO objects children collection because the values for any
|
||||
multiple/variable return type formats can vary at runtime, based on your current selected
|
||||
DocVersion and the Selected Slave (Unit) / OtherChild Override.
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildByRoid]
|
||||
(
|
||||
@RofstID int,
|
||||
@Roid VarChar(50)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
-- Only use the first (12) characters to lookup an RoChild by its roid
|
||||
-- If its a (16) digit roid, then use its last (4) characters [roidExt ==> specific to a return type value]
|
||||
-- to select the specified return value format type in the code once all of the children Ro Return types have
|
||||
-- been loaded into memory in the code
|
||||
|
||||
Set @Roid = Left(@Roid + '00000000', 12);
|
||||
|
||||
Select rc.ROFstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Where rc.RofstID = @RofstID
|
||||
And rc.roid = @Roid;
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByRoid] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByRoid] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
|
||||
-- Delete All Existing Rofst Table Data
|
||||
Delete From RofstHeader;
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
End: B2022-083: Support Conditional RO Values (v2.1)
|
||||
==========================================================================================================
|
||||
*/
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
/*
|
||||
@@ -20073,7 +20967,7 @@ GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2021 - Volian Enterprises, Inc. All rights reserved.
|
||||
Copyright 2022 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision]
|
||||
WITH EXECUTE AS OWNER
|
||||
@@ -20085,8 +20979,8 @@ BEGIN TRY -- Try Block
|
||||
DECLARE @RevDate varchar(255)
|
||||
DECLARE @RevDescription varchar(255)
|
||||
|
||||
set @RevDate = '07/12/2022 11:15 AM'
|
||||
set @RevDescription = 'ROFST Lookup / Memory Fixes (v2.0) - New procedures for Reduction of Memory Use'
|
||||
set @RevDate = '07/27/2022 1:20 PM'
|
||||
set @RevDescription = 'B2022-083: Support Conditional RO Values (v2.1)'
|
||||
|
||||
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
||||
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
||||
|
Reference in New Issue
Block a user