Use the template-specific data model wizard
- Last UpdatedFeb 10, 2023
- 4 minute read
- PI System
- PI SQL Commander Lite 2021
- Developer
The Template-Specific Data Model wizard uses attribute templates that are associated with PI AF element templates or PI AF event frame templates to define the format of metadata. Thus, each table-valued function (TVF) is tightly bound to a template. For more information, see View TVFs and function tables.
Note: The Template-Specific Data Model wizard is available only if PI SQL Commander Lite is connected to PI SQL Client.
Use the wizard to generate template-specific data models that contain Views, Sampled Value(s) TVFs, and Summaries TVFs.
-
To start the wizard, in the Object Explorer pane right-click the Schema folder or any subfolder, and click Create Template-Specific Data Model.
For more information, see Object Explorer.
The Template-Specific Data Model wizard is displayed with the Template section.
-
Select Element or Event Frame and a template, and click Next.
The list of element and event frame (PI AF) templates depends on the database you are working with. If the element or event frame template list is empty, the PI AF database to which you are connected has no PI AF element or event frame templates. For further details about PI AF element and event frame templates, see the PI System Explorer User Guide available at the AVEVA Customer Portal Products page or the PI System Explorer Help.
Note: If the Next button is grayed out, it means that the template cannot be selected because it does not have any attributes.
The Data Model Objects section is displayed.
-
Click on the view or the table-valued function that you want to create. The following options are available:
-
Add Element View
-
Add GetSampledValue
-
Add GetSampledValues
-
Add GetSummary
-
Add GetSummaries
The Column Definition window for the view or table-valued function opens.
-
-
In the Column Definition window, drag and drop the attribute(s) that you want from the left to the right pane and select the Calculation Basis and Summary Type for each attribute.
Note: Only attributes with underlying numerical data types such as integer or double will provide a reasonable function result. Check the data type in the PI System Explorer.
For information about the calculation basis or the summary type, see AFCalculationBasis Enumeration and AFSummaryTypes Enumeration in the AF SDK Reference.
The following image shows an example of column definition of the GetSummaries table-valued function.

Note: If a data model object with that name already exists, the name is displayed in red. If this occurs, enter a new name for the data model object.
-
Optional: If you do not want to see the Unit of Measure, Error, or Timestamp column, clear the column checkbox or leave the field blank.
-
The Timestamp column is available if the Summary Type is either Minimum or Maximum.
-
In the Desired unit of measure column, select the unit of measure to display for the attribute. This column is available if the Summary Type is one of the following: Average, Minimum, Maximum, Range, StdDev, or PopulationStdDev.
-
Click OK.
-
-
Click Next.
The Summary section is displayed.
-
Review the summary of the data model and click Execute to run the DML (data manipulation language).
The Execution section is displayed.
-
Review the results and then click Done.
The DML creates the data model object that you specified in the Data Model Objects section. Subsequently, either one of the following is displayed in the Status column:
-
indicates a successful creation of the database object(s).
-
indicates an unsuccessful creation of the database object(s). Hold the mouse over
the icon to view the error.
Note: The data model object types Catalog and Schema are only listed in the details if they were created for the first time. If you selected a subfolder when you started the wizard, the existing data model object types.
-
-
In the Object Explorer pane, right-click the Catalogs folder and click Refresh.
The folders for the new objects are displayed.