Skip to main content

Read the latest data record

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

You can, of course, set optional filter criteria, for example, if the table contains multiple measurement series.

Variant 1: Timestamp Sorting Without Filters

Required Fields/Columns:

NameDescription
<zeitstempel>Timestamp of type Date/Time, used for sorting
<werte>Column(s) containing the relevant values

Configure a DB transfer object with the following properties:

NameConfiguration
Data Source_<Ihre Datenbankanbindung aus dem Plug-ins-Bereich> _
TypeSelect

Tab: General

NameConfiguration
Table_<Tabelle, die Ihre Daten enthält> _
ColumnsMove all required value columns from Available to Used.

Tab: Filter

NameConfiguration
FilterNo additional filters in this variant

Tab: Query

NameConfiguration
Sort OrderDescending – this places the most recent record at the top.
Sort Column_<Zeitstempel-Spalte> _
Do not change recordsSelected. The data record is transferred again with each call; the source table remains unchanged.
Limit number of records toEnabled, value 1 – only the topmost and thus most recent data record is transferred.
With empty SELECTAs needed: Abort transfer, Return read error, or Return empty record.
note

Exactly one of the three options for handling the transferred records is always selected, as is one of the three options under With empty SELECT.” All properties of the tab are described at DB Select Transfer Object.

Database Select Transfer Object

Your transfer object appears in the flow as shown in the following figure. In this 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 Flow configuration:

Transfer Object

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

Variant 2: Timestamp Sorting with an Additional Filter

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

Required Fields/Columns:

NameDescription
<zeitstempel>Timestamp of type Date/Time, used for sorting
ConfigIDID of the measurement series
<werte>Column(s) containing the relevant values

Configure a DB transfer object with the following properties:

NameConfiguration
Data Source_<Ihre Datenbankanbindung aus dem Plug-ins-Bereich> _
TypeSelect

Tab: General

NameConfiguration
Table_<Tabelle, die Ihre Daten enthält> _
ColumnsMove all required value columns from Available to Used.

Tab: Filter

NameConfiguration
FilterAdd filter creates a new filter.
Edit filter/filter group

Column: ConfigID

Comparison operator: EQUAL

PreviewThis should now read: WHERE (ConfigID = ?)

Tab: Query

NameConfiguration
Sort OrderDescending – this places the most recent record at the top.
Sort Column_<Zeitstempel-Spalte> _
Do not change recordsSelected. The data record is transferred again with each call; the source table remains unchanged.
Limit number of records toEnabled, value 1 – only the topmost and thus most recent data record is transferred.
With empty SELECTAs needed: Abort transfer, Return read error, or Return empty record.

Database Select Transfer Object

Your transfer object looks like the one shown in the figure. The DB transfer object with a filter requires a two-step transfer: The first step (blue arrowhead) defines the filter, and the second (green) retrieves the value.

Fill the filter with a value:

  1. Create a constant object and enter the desired ConfigID there.
  2. Establish a connection between the constant and the ConfigID filter element of the DB transfer object using an Item Link.

Transfer Object

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

Option 3: Timestamp Sorting with an Additional Filter from a Template

Option 2 can also be configured as a “” flow template: . Create one instance for each series of measured values.

  1. Do not configure a flow; instead, configure a flow template with the same settings for the DB transfer object as in Variant 2.
  2. In the constant object from Variant 2, do not enter the value; instead, enter the template variable {ConfigID}.
  3. Configure the time trigger as in Variant 2.
  4. Create an instance for each measured value series from the template and enter the value for the ConfigID.

The template contains the time trigger, the constant object with the template variable, and the DB transfer object with the filter:

 Flow template with a time trigger, a constant object containing the template variable ConfigID, and a DB-Select transfer object named

When creating an instance, assign a name to it, select the destination folder, and populate the template variable ConfigID with the value of the measurement series:

 Dialog for creating an instance with instance name, destination folder, and the template variable ConfigID

In the completed instance, the specific value is stored in the constant object; to the left of it, you can see the instance’s template variables:

 Instance generated from the template with the specific ConfigID value in the constant object

Complete the flow

The data source has been configured up to this point. Three steps remain to make the flow operational:

  1. Connect the data destination. Use Item Links to connect the elements of the DB transfer object to the transfer object of your target system. The available target systems and the properties of their transfer objects are described in the chapter for each respective plug-in: all plug-ins from A to Z .
  2. Go live. In the “” view, select “Publish” , select the changes, and click Make changes productive.” Until then, the runtime continues to operate using the most recently published version.
  3. Check the result. The “” status display shows whether the flow is running. In the “ Flow Status” , you can view each individual transfer and the transferred values.