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

Reading the last number of Tag Meta Data with Local timestamp

8min

Use Cases

As tag Meta data can be very infrequent and users may not always know the last time stamp, Litmus Production Record Database allows to return the last recorded values. Returning these last 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_GetLastTagMetaDataLocalTime 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

@NumberOfResults

INTEGER

How many results are to be returned?



If no specific number of results is set, the value can also be DEFAULT which will assume the value null which is equivalent to 1.

2







DEFAULT

@Timezone

INTEGER

The Number of hours your local time zone is ahead or behind the GMT time zone. If the user does not know this value, it can be left as DEFAULT which will assume the value 0 or GMT. The value can be positive (example: 8 for UTC +8) or negative (example: -6 for UTC -6)

2









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_GetLastTagMetaDataLocalTime] ( DEFAULT ,DEFAULT ,DEFAULT ,2 ,2);

Result

The function returns a table as result.

Read last Tag Meta Data Local time
Read last Tag Meta Data Local time


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_GetLastTagMetaDataLocalTime] ( 'ToolCtr_Axis_X' ,'ToolCtr_V1_3BSM_Makino1' ,DEFAULT ,1 ,2);

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



Reduced result set last tag meta data Local time
Reduced result set last tag meta data Local time


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_GetLastTagMetaDataLocalTime]( 'ToolCtr_Axis_X' ,'ToolCtr_V1_3BSM_Makino1' ,DEFAULT ,1 ,2) order by TagValue asc;

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



sorted result set last tag meta data local time
sorted result set last tag meta data local time