Solutions
...
Litmus Production Record Datab...
Interacting with Litmus Produc...

Reading Tag Meta Data with UTC timestamp

8min

Use Cases

Returning tag Meta data recorded by Litmus Production Record Database through the use of these SELECT statements can be used for example by any visualization platform which allows to integrate with MSSQL like;

  • Grafana
  • PowerBI
  • Tableau

Further can these queries be used by any other application which allows for an ODBC connection such as:

  • Excel
  • C#
  • .Net
  • Python
  • R

They can also be part of a larger stored procedure developed by users with T-SQL.

Method

Run SELECT query with Function PROREC_Tag_GetTagMetaDataUTC as FROM clause.

Note

Tag Meta data are a subset of data which can be stored for a tag and are updated infrequently. This can be data such as Alarm Limits, descriptions or anything usable to further describe a tag.

Input Variables

Variable name

Datatype

Description

Example

@Tag

VARCHAR(50)

The Tag name. If no specific Tag name is to be queried or to get a list of Tag name's, the value can also be DEFAULT which will assume the value %.

Pressure





DEFAULT

@Device

VARCHAR(50)

The device name for the tag.



If no specific device is to be queried or to get a list of devices, the value can also be DEFAULT which will assume the value %.

Asset1





DEFAULT

@Item

VARCHAR(50)

The Meta Data item of the tag which the value represents.



If no specific Meta Data item is to be queried or to get a list of item's, the value can also be DEFAULT which will assume the value %.

High_High_Limit







DEFAULT

@TagValue

VARCHAR(256)

A specific value for the Item of the Tag.



If no specific Value for the Item is to be queried or to return all Values, the value can also be DEFAULT which will assume the value %.

20







DEFAULT

@Quality

VARCHAR(4)

A specific quality of the tag value. (GOOD or BAD)



If no specific quality for the value is to be queried or to return all qualities, the value can also be DEFAULT which will assume the value %.

GOOD







DEFAULT

@StartTime

DATETIME

The start of the time period for which to query data.



The time will be treated as in local time and will be adjusted to UTC using the @Timezone value.



If no specific start time is required, the value can also be DEFAULT which will assume the value null. This will trigger the function to calculate a start time of -1h from the current time stamp.



This means the default time period for which data are returned is always the last hour.

2023-03-09 12:57:59.200

















DEFAULT

@EndTime

DATETIME

The end of the time period for which to query data.



The time will be treated as in local time and will be adjusted to UTC using the @Timezone value.



If no specific end time is required, the value can also be DEFAULT which will assume the value null. This will trigger the function to use the current time stamp.



This means the default time period for which data are returned is always the last hour.

2023-03-10 12:57:59.200

















DEFAULT

How to use

To query tag data, execute a SELECT statement from the function PROREC_Tag_GetTagMetaDataUTC providing all the required inputs. Below is an example using T-SQL in SQL Server Management Studio:

SELECT * FROM [LE_ProductionRecord].[dbo].[PROREC_Tag_GetTagMetaDataUTC] ( DEFAULT ,DEFAULT ,DEFAULT ,DEFAULT ,DEFAULT ,'2022-12-01 14:13:21.000' ,DEFAULT );

Result

The function returns a table as result.

Read Tag Meta Data UTC
Read Tag Meta Data UTC


Additional Options

It is possible to reduce the number of columns returned by the SELECT statement. Below is an example using T-SQL in SQL Server Management Studio:

SELECT RecordTime, Item, TagValue FROM [LE_ProductionRecord].[dbo].[PROREC_Tag_GetTagMetaDataUTC] ( 'ToolCtr_Axis_X' ,'ToolCtr_V1_3BSM_Makino1' ,DEFAULT ,DEFAULT ,DEFAULT ,'2022-12-01 14:13:21.000' ,DEFAULT);

This will reduce the number of columns returned to only the three selected.

Reduced result set tag meta data utc
Reduced result set tag meta data utc


It is possible to sort data based on users requirements returned by the SELECT statement. Below is an example using T-SQL in SQL Server Management Studio:

SELECT RecordTime, Item, TagValue FROM [LE_ProductionRecord].[dbo].[PROREC_Tag_GetTagMetaDataUTC] ( 'ToolCtr_Axis_X' ,'ToolCtr_V1_3BSM_Makino1' ,DEFAULT ,DEFAULT ,DEFAULT ,'2022-12-01 14:13:21.000' ,DEFAULT ) order by TagValue asc;

The result will be a table, where all rows are sorted by their TagValue in ascending order.

sorted result set tag meta data utc
sorted result set tag meta data utc