Skip to main content
InSource KnowledgeCenter

TN AppSvr322 Wonderware Application Server Object Template and Instance Hierarchy

Description

This article from InSource shows how to query the Wonderware GR/Galaxy Repository for Application Server object template and instance hierarchy.

  • Author: Bruce Telford
  • Published: 06/14/2019
  • Applies to: System Platform 2017 Update 2 (should work on earlier versions as well)

Details

There are times when one might need object and template configuration information for documentation or other purposes. This query will provide all templates and object instance based on the parent template specified in the anchor member where clause in the query below (Example: replace the “$UserDefined” below with the template you are looking for below).

WITH ObjectInstances (HierarchyID, Hierarchy, ObjectID, DerivedFrom, TagName, HierarchicalName, Container, Area, IsTemplate, IsDeployed, ObjLevel, Seq)

AS

(

       -- Anchor member definition

       SELECT '/'+ CAST([gobject_id] AS nvarchar(max)) AS HierarchyID

              , CAST([tag_name] AS nvarchar(max)) AS Hierarchy

              , [gobject_id] AS ObjectID

              , [derived_from] AS DerivedFrom

              , [tag_name] AS TagName

              , [hierarchical_name] AS HierarchicalName

              , [mycontainer] AS Container

              , [myarea] AS Area

              , [is_template] AS IsTemplate

              , [is_deployed] AS IsDeployed

              , 0 AS ObjLevel

              , CAST(ROW_NUMBER() OVER (ORDER BY [tag_name] ASC) AS float) AS Seq

       FROM [internal_common_obj]

       --WHERE [derived_from] = 0

       WHERE [tag_name] = '$UserDefined'

 

       UNION ALL

 

       -- Recursive member definition

       SELECT oi.HierarchyID +'/'+ CAST(o.[gobject_id] AS nvarchar(max)) AS HierarchyID

              , oi.HierarchicalName +' > '+ CAST(o.[tag_name] AS nvarchar(max)) AS Hierarchy

              , o.[gobject_id] AS ObjectID

              , o.[derived_from] AS DerivedFrom

              , o.[tag_name] AS TagName

              , o.[hierarchical_name] AS HierarchicalName

              , o.[mycontainer] AS Container

              , o.[myarea] AS Area

              , o.[is_template] AS IsTemplate

              , o.[is_deployed] AS IsDeployed

              , ObjLevel + 1 AS ObjLevel

       , CAST(oi.Seq + ((1/power(100.0,(ObjLevel+1))) * (ROW_NUMBER() OVER (ORDER BY [TagName] ASC))) AS float) AS Seq

       FROM [internal_common_obj] AS o

              INNER JOIN ObjectInstances AS oi ON oi.ObjectID = o.[derived_from]

 

)

SELECT SUBSTRING(HierarchyID, 2, 60) AS HierarchyID

       , Hierarchy, ObjectID, DerivedFrom, TagName, HierarchicalName, Container, Area, IsTemplate, IsDeployed, ObjLevel, Seq

FROM ObjectInstances 

ORDER BY HierarchyID, ObjLevel, Seq;

 

The Results will look something like the following:

clipboard_ec553e29bd9a05231225abaf48136e368.png

NOTE: Tested on System Platform 2017 Update 2 (should work on earlier versions as well)