Integrating SQL Database Seeding Into the Automated Workflow

Introduction

This section explains how could the SQL database seeding files be included in the workflow so they are executed automatically during software installation or upgrade.

Equipment Model SQL Update Snippets

Add New Equipment Model

INSERT INTO Equipments(Attribute)VALUES();
AttributeTypeRequiredDescription
IdGUIDYesUnique identifier
NameVARCHARYesDisplay name of the equipment
Base(Id)GUIDNoThe parent class from which equipment properties will be inherited.
AbstractBITNoIndicates whether the class is abstract
CommandBITNoIndicates whether the class supports commands
InterfacesVARCHARNoInterfaces implemented by the equipment
Image(Id)INTEGERNoIcon/image ID

Important: The Id value must be specified when inserting new, as it is not generated automatically.


The screenshot is for illustration purposes only. Please replace with your own values.


Add New Equipment Property Info

INSERT INTO EquipmentPropertyInfos(Attribute, Equipment)VALUES();
AttributeTypeRequiredDescription
IdGUIDYesUnique identifier
DisplayName(Name)VARCHARYesProperty name
Equipment(EquipmentId)GUIDYesThe related equipment
TypeINTEGERNoProperty type
DescriptionVARCHARNoProperty description
ApplicationTypeINTEGERNoApplication type
ReferenceTargetVARCHARNoReference target
ValueMin (MinVal)INTEGERNoMinimum value
ValueMax(MaxVal)INTEGERNoMaximum value
DefaultValue(DefVal)INTEGERNoDefault value
UnitVARCHARNoMeasurement unit
DisplayFormatVARCHARNoDisplay formatting
AttributesVARCHARNoAttributes flags
CompressionMethodINTEGERNoCompression method
CompressionErrorDOUBLENoAllowed compression error
SubstituteMethodINTEGERNoSubstitute method on error
SubstituteValueINTEGERNoSubstitute value
NoiseFilterEnableBITNoEnable noise filter
NoiseFilterFactorDOUBLENoNoise filter factor
TargetHistoryINTEGERNoTarget history configuration
RecordingMethodINTEGERNoRecording method
ProcessingMethodINTEGERNoProcessing method
HistorizedBITNoSpecifies if history data is collected
HistoryCollectionTemplatesVARCHARNoHistory collection templates
ApprovedBITNoApproval flag
ValueDisplayMinINTEGERNoMinimum display value
ValueDisplayMaxINTEGERNoMaximum display value
MaxArrayLengthBITNoMax array length
VariableLengthArrayBITNoVariable length array
MaxStringLengthINTEGERNoMax string length
StreamStatusStoringBITNoStream status storing
StreamTimestampStoringBITNoStream timestamp storing
StreamCompressionBITNoStream compression method
StreamPeriodLengthINTEGERNoStream period length
StreamPeriodLengthUnitTINYINTNoUnit of stream period length
ConnectedBooleanNoIs connected
DiscreteValueBITNoIs discrete value
EventsBITNoEvent configuration
PreventDisableOnInitBITNoPrevent disabling of the property during initialization.
BinaryTextIdINTEGERNoBinary text ID
SymbolGroupINTEGERNoSymbol group
SourceINTEGERNoSource reference
UserStatusIdINTEGERNoUser status ID
InvertedINTEGERNoIs inverted
IsNullableBITNoNullable flag
IsVisibleToUserByDefaultBITNoVisible to user by default
RangeCheckBITNoEnable range check
RangeCheckManuallyEnteredBITNoManually entered range check
EditMaskingVARCHARNoEdit masking options
VisibilityRequirementVARCHARNoVisibility requirement

The screenshot is for illustration purposes only. Please replace with your own values.

Important: The Id value must be provided when inserting a new record. It is not generated automatically.


Add New Equipment Instance

INSERT INTO Paths(Parent[ParentId],Attribute)VALUES();
Column NameData TypeRequiredDescription
Id(PathId)GUIDYesUnique identifier for each path record.
NameVARCHARYesFull internal path name (often hierarchical, e.g. Motor.Motor_U2009).
DisplayNameVARCHARNoHuman-readable display name (e.g. Motor_U2009).
Parent(ParentId)GUIDYesReference to parent path object.
Equipment(EquipmentId)GUIDNoReference to the associated class in equipment(s) table.
ReferencesVARCHARNoOptional external or logical reference; often NULL.

Important: The PathId value must be provided when inserting a new record. It is not generated automatically.


The screenshot is for illustration purposes only. Please replace with your own values.


Update Equipment Model

UPDATE EquipmentsSET Attribute ='New Value' WHERE Mask(Name/Id) = '';

The screenshot is for illustration purposes only. Please replace with your own values.


Update Equipment Property Info

UPDATE EquipmentPropertyInfos SET Attribute='New Value' WHERE Mask(DisplayName[Name]/Id) = '' AND Equipment(EquipmentId)='';

The screenshot is for illustration purposes only. Please replace with your own values.


Update Equipment Instance

UPDATE Paths SET Attribute='New Value' WHERE Mask(Name/Id[PathId]);

The screenshot is for illustration purposes only. Please replace with your own values.


Disconnect Equipment Property Info

The “Connected” attribute is designed for temporary use to isolate bad or suspicious values originating from unknown sources. A replacement value can then be provided manually until the underlying issue is resolved.

Disconnect specific equipment property

UPDATE EquipmentPropertyInfos SET Connected=0 WHERE Mask(DisplayName[Name]/Id)='' AND Equipment(EquipmentId)='';

The screenshot is for illustration purposes only. Please replace with your own values.


Disconnect all equipment properties associated with the specified equipment class

UPDATE EquipmentPropertyInfos SET Connected=0 WHERE Equipment(EquipmentId)='';

The screenshot is for illustration purposes only. Please replace with your own values.


Disable Equipment Instance

When an equipment instance is disabled, only future real-time interactions are stopped, the asset is marked as legacy, and system overhead is reduced. Disabling an instance allows equipment to be reactivated in the future.

This approach is safer for handling equipment that is no longer in operation but whose history remains valuable for data analysis. The instance continues to function as a data source within the application.

AttributeData TypeDescription
IdVARCHARUnique identifier.
InputBITFlags like 0/1 to enable/disable input.
OutputBITFlags like 0/1 for output enabled/disabled.
TargetReferenceVARCHARPath or ID string to the data source.
TargetVARCHARLogical name or label of the data source.
OwnerComponentINTEGERName of the owning component (e.g., “OPC”).
AccessTypeTINYINTAccess mode like “Realtime” or “Historical”.
AccessPathVARCHARAdditional path information.
RowModificationTime_UTCTIMESTAMPTimestamp of last modification in UTC.
TGT:OwnerComponentVARCHARLikely same as OwnerComponent but for linked target.
TGT:AccessTypeVARCHARSame as AccessType but for linked target.
TGT:RowModificationTimeTIMESTAMPTimestamp of linked target’s last modification.

Disable data production for an entire class or path hierarchy

UPDATE DataAccessSources SET input=0  WHERE Id LIKE '%/Path_Name/%';

The screenshot is for illustration purposes only. Please replace with your own values.


Disable data production for specific equipment instances

UPDATE DataAccessSources SET input=0  WHERE Id LIKE '%/Path_Name/Instance%';

The screenshot is for illustration purposes only. Please replace with your own values.



Warning on Naming Conflicts

A disabled instance remains in the system but is inactive. It retains its unique identifier and name, ensuring traceability and potential future reactivation. The name of a disabled instance cannot be reused for a new instance.


Deletion Overview

RTDB won’t immediately shrink files on disk when you delete rows. When old instances are deleted and replaced with new ones, physical disk reclamation is generally not required. In this scenario:

  • Row deletion removes data logically.
  • The released storage becomes internally reusable.
  • New data can reuse this storage without increasing the database file size.

If deletion is expected to reclaim disk space, explicit maintenance must be performed. The following documentation may help: Hard Deletion to Free up Disk Space.


Delete Equipment Model

The deletion cascades to the related EquipmentPropertyInfo and Path (equipment instances). However, the equipment model may still appear in the node tree, even though its instances are no longer available as data source. This action carries significant risk and is not recommended. The preferred solution is to disable it instead.

DELETE FROM Equipment(s) WHERE Mask(Name/Id)IN();

The screenshot is for illustration purposes only. Please replace with your own values.


Delete Equipment Property Info

When a property is deleted, the change cascades to the related Path rows (equipment instances). As a result, the affected equipment instances can no longer display the deleted property and its values. This action carries significant risk and is not recommended. The preferred solution is to disable it instead.

DELETE FROM EquipmentPropertyInfo(s) WHERE Mask(DisplayName[Name]/Id)='' AND Equipment(EquipmentId)='';

The screenshot is for illustration purposes only. Please replace with your own values.


Delete Equipment Instance

The metadata reference (equipment instance row) is removed. The time-series data remains intact, but it can no longer function as data source in the application. This action carries significant risk and is not recommended. The preferred solution is to disable it instead.

DELETE FROM Path(s) WHERE Mask(Name/Id[PathId])IN();

The screenshot is for illustration purposes only. Please replace with your own values.


Integrating SQL Execution Into the Automated Workflow

Where to Place Your SQL Files?

Place them in the appropriate component directory:

packagesetup\ComponentName\

RTDB Service Manager automatically detects and executes the SQL Equipment Model updates.

Steps

  1. Manually create a component folder under packagesetup.
  2. Put SQL files inside that folder.
  3. Stop the RTDB and applications.
  4. Start the RTDB.

Done!


Note: Possible causes of SQL execution failure include incorrect table names, invalid ID formats, mismatched columns and values, or the process cannot access the file because it is being used by another process.