Skip to main content
Version: 5.5

... read out a current data record?

To read out a current data record from a database table, sort the table in descending order by the timestamp field and transfer only one data record. The database must be polled at the required interval using a time trigger. In this variant, the current data record is transferred each time the function is called. To transfer only one new record, continue reading in the next chapter.

You can, of course, set optional filter criteria, e.g., if the table contains several measurement series.

Variant 1: Timestamp sorting without filter

Required fields/columns:

NameDescription
<zeitstempel>Timestamp of type date/time, according to which sorting is performed
<werte>Column(s) with the relevant values

Configure a DB transfer object with the following properties:

NameConfiguration
DB connection<ihre db-anbindung="" aus="" der="" plug-in-konfiguration="">
TypeSelect

Tab: General

NameConfiguration
Table<tabelle, die="" ihre="" daten="" enthält="">
Available columns/Used columns<alle werte-spalten="">

Tab: Filter (Queries, Update, Delete)

NameConfiguration
FilterNo further filters in this variant

Tab: Query

NameConfiguration
Do not change recordsActivate if the records are not to be changed
Mark transferred recordsActivate if transferred records are to be used. The corresponding records can be selected in the column for marking.
Delete transferred recordsActivate if transferred records are to be deleted.
Sort by column<zeitstempel-spalte>
Sort orderDescending (newest value at the top)
Limit number of records to1 (only the first record = the newest should be transferred)
Trigger read errorAs needed
Cancel transferas needed

Your transfer object looks like the one in the next figure in the connection. In the example, the Value column was used as the value column. It is now available as a data source. You cannot see the sorting in the connection project planning:

Plan another time trigger with the required interval, e.g., 10 seconds. Then, every ten seconds, the latest data record from the table is transferred, regardless of whether it has already been transferred or not.

Variant 2: Timestamp sorting with additional filter

In this variant, the table contains several measurement series, each of which is defined by a ConfigID. An additional filter must be configured.

Required fields/columns:

NameDescription
<zeitstempel>Timestamp of type date/time, according to which sorting is performed
ConfigIDID of the measurement series
<werte>Column(s) with the relevant values

Project a DB transfer object with the following properties:

NameConfiguration
DB connection<ihre db-anbindung="" aus="" der="" plug-in-konfiguration="">
TypeSelect

Tab: General

NameConfiguration
Table<tabelle, die="" ihre="" daten="" enthält="">
Available columns/Used columns<alle werte-spalten="">

Tab: Filter

NameConfiguration
Filter"Add filter" creates a new filter.
Edit filter/filter group

Column: ConfigID

Comparison operator: EQUAL

PreviewThis should now read: WHERE (ConfigID = ?)

Tab: Query

NameConfiguration
Sort by column<zeitstempel-spalte>
Sort orderDescending (newest value at the top)
Limit number of records to1 (only the first record = the newest should be transferred)
Error if query result is emptyAs needed
Cancel transfer if query result is emptyas needed

Your transfer object looks like the one in the illustration. Remember to fill the filter with a value, e.g., using a constant object. The DB transfer object with filter requires a two-step transfer. The first step (blue arrowhead) defines the filter, the second, green, reads the value. Since the data destination can be arbitrary, this is only mentioned here in passing.

Configure a time trigger with the required interval, e.g., 10 seconds. Then, every ten seconds, the latest data record from the table is transferred, regardless of whether it has already been transferred or not.

Variant 3: Timestamp sorting with additional filter from template

Variant 2 is also suitable for configuration via a connection template.

  1. Instead of configuring a connection, configure a connection template with the same settings for the DB transfer object as in variant 2.
  2. In the constant object, do not enter the value, but a template variable {ConfigID}.
  3. Project the time trigger as in variant 2.
  4. Create an instance from the template and enter the value for the ConfigID.

This allows you to quickly create connections for all existing measurement series (=ConfigIDs): one instance per ConfigID. Figure above: Template; Figure below: Instance.