| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -19791,9 +19791,11 @@ GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					*****************************************************************************/
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					/*
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					==========================================================================================================
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Author:			Jake Ropar
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Create Date:	06/23/2022
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Description:	Inserts New Rofst Child Record / Default Values
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Modified:		02/19/2025
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Modification 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Description:    Added support for ROs with brackets in Unit Values
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					==========================================================================================================
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					*/
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Create Procedure [dbo].[vesp_RofstChildInsert]
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -19806,19 +19808,26 @@ GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@title VarChar(Max),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@roid VarChar(50),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@appid VarChar(Max) = null,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@value VarChar(Max) = null
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@value VarChar(Max) = null,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@missingDefaultValue VarChar(Max) = null
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					With Execute as Owner
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					As
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @AccPageID VarChar(Max) = null;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @BaseAccPageID VarChar(Max) = null;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @DefaultValues VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @RoidExt VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @AccPageExt VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						-- Create Rofst Child/Group Record
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						-- Default missing value if Null (Null values not allowed for the [value] field in the RofstDefaultValue table
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (DataLength(IsNull(@missingDefaultValue, '')) <= 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Set @missingDefaultValue = '[TBD]';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						-- 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);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Values (@RofstID, @ID, @ParentID, @dbiID, @type, @title, @roid, @appid, REPLACE(REPLACE(@value, '&123;', '{'), '&125;', '}'));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						-- Check for appid, if exists, then insert the default value for each return type if multi-value
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -19826,37 +19835,58 @@ GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							-- Get Accessory Page ID
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Select @AccPageID = Concat(d.dbiAP, '-', @appid) 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							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 (Parent RoChild) [roid = 12]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Values (@RofstID, @roid, Replace(@title, '\u160?', ' '), @AccPageID);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Select @DefaultValues = dbo.vefn_RofstDataReplaceVars(@value);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							-- Insert Rofst Default Value(s) (Children RoChild) [roid = 16] (Do Not Insert Duplicates)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							If (PatIndex('%=%', @DefaultValues) > 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									-- Insert Rofst Default Values (Multi-Values) --> [Roid = (16) Digits]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Select @DefaultValues = Replace(@DefaultValues, '{', ''); 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							With ChildrenValues as 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Select (x.ListPosition + 40)  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, Cast(Format(Min(OffsetIndex), 'D4') as VarChar(4)))  as 'roid',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								DefaultValue as 'value',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								null as 'AccPageID'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							From ChildrenValues
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Group By DefaultValue
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Order By Min(OffsetIndex) Asc
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									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 (DataLength(cv.DefaultValue) > 0) Then 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										      REPLACE(REPLACE(REPLACE(dbo.vefn_RofstDataCleanUnitInfoTags(cv.DefaultValue, 0), '&123;', '{'), '&125;}', '}'), '&125;', '}')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										      Else @missingDefaultValue 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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									-- Insert Rofst Default Value (Single Value) --> [Roid = (16) Digits]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Select @RofstID as 'RofstID',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										Concat(@roid, re.RoidExt) as 'roid',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										Case When (DataLength(@DefaultValues) > 0) Then 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										      REPLACE(REPLACE(REPLACE(dbo.vefn_RofstDataCleanUnitInfoTags(@DefaultValues, 0), '&123;', '{'), '&125;}', '}'), '&125;', '}')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										      Else @missingDefaultValue End as 'value',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										Concat(@BaseAccPageID, '.', re.AccPageExt) as 'AccPageID'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									From vwRofstData_RofstExtensions re 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Where re.Offset = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								End
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						End -- (Len(@appid) > 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					End
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Go
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -20448,98 +20478,6 @@ GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					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]
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -21239,121 +21177,6 @@ GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				==========================================================================================================
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				*/
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstChildInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    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:	Inserts the RO Child object and associated return values
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				==========================================================================================================
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				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);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Declare @RoidExt VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Declare @AccPageExt 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;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Select @DefaultValues = dbo.vefn_RofstDataReplaceVars(@value);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						If (PatIndex('%=%', @DefaultValues) > 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								-- Insert Rofst Default Values (Multi-Values) --> [Roid = (16) Digits]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Select @DefaultValues = Replace(@DefaultValues, '{', ''); 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								-- Insert Rofst Default Value (Single Value) --> [Roid = (16) Digits]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Select @RofstID as 'RofstID',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Concat(@roid, re.RoidExt) as 'roid',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Case When (Len(RTrim(LTrim(@DefaultValues))) > 0 ) Then dbo.vefn_RofstDataCleanUnitInfoTags(@DefaultValues, 0) Else '[TBD]' End as 'value',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Concat(@BaseAccPageID, '.', re.AccPageExt) as 'AccPageID'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								From vwRofstData_RofstExtensions re 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Where re.Offset = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							End
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceVars' AND type in (N'FN'))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				DROP FUNCTION [dbo].[vefn_RofstDataReplaceVars]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				GO
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -21632,124 +21455,6 @@ GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					ELSE PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Error on Creation'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					GO
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					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:	Inserts the RO Child object and associated return values
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					==========================================================================================================
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					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,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						@missingDefaultValue VarChar(Max) = null
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					With Execute as Owner
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					As
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @BaseAccPageID VarChar(Max) = null;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @DefaultValues VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @RoidExt VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Declare @AccPageExt VarChar(Max);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						-- Default missing value if Null (Null values not allowed for the [value] field in the RofstDefaultValue table
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (DataLength(IsNull(@missingDefaultValue, '')) <= 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Set @missingDefaultValue = '[TBD]';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						-- 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;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Select @DefaultValues = dbo.vefn_RofstDataReplaceVars(@value);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							If (PatIndex('%=%', @DefaultValues) > 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									-- Insert Rofst Default Values (Multi-Values) --> [Roid = (16) Digits]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Select @DefaultValues = Replace(@DefaultValues, '{', ''); 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									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 (DataLength(cv.DefaultValue) > 0) Then dbo.vefn_RofstDataCleanUnitInfoTags(cv.DefaultValue, 0) Else @missingDefaultValue 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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								Begin
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									-- Insert Rofst Default Value (Single Value) --> [Roid = (16) Digits]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Select @RofstID as 'RofstID',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										Concat(@roid, re.RoidExt) as 'roid',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										Case When (DataLength(@DefaultValues) > 0) Then dbo.vefn_RofstDataCleanUnitInfoTags(@DefaultValues, 0) Else @missingDefaultValue End as 'value',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										Concat(@BaseAccPageID, '.', re.AccPageExt) as 'AccPageID'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									From vwRofstData_RofstExtensions re 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									Where re.Offset = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								End
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				/*
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				==========================================================================================================
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 End: B2022-124: [JPR] Blank RO Values (All Spaces) printing as ?
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -24132,8 +23837,8 @@ BEGIN TRY -- Try Block
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DECLARE @RevDate varchar(255)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DECLARE @RevDescription varchar(255)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					set @RevDate = '10/28/2024 11:24'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					set @RevDescription = 'Add the ability for PROMS to remember the procedure tabs that were open when you closed PROMS'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					set @RevDate = '2/19/2025 11:24'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					set @RevDescription = 'Added support for legacy ROs with brackets in Unit Values'
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Select  cast(@RevDate as datetime) RevDate, @RevDescription  RevDescription
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				 
 |