Write DB values to tags (Batch transfer)

<< Click to Display Table of Contents >>

Manual > Monitoring system construction guide > Server logic construction >

Write DB values to tags (Batch transfer)

overview

Here we will explain the process of writing the contents of data stored in a table in a database to tags in bulk.

 

By using this function, for example, recipe information stored on a table can be written to a PLC in bulk via tags.

 

Action used: Batch transfer (ODBC → Tag) Action

 

 

 

Download the sample

The creation examples shown on this page are provided with samples.

 

The sample can be downloaded from below.

 

The above sample includes a SQL file (DDL) to generate the table. Use it as a reference when creating the table.

 

 

 

Operation check

This sample requires a database to be prepared. Once the database is prepared, please bring the sample server configuration file online from FA-Server (yellow arrow).

 

After going online, please confirm that when you write TRUE to U01.F01.T01, the value set in the database table is written to the tag. To check the written value, start monitoring with a tag operation or use the tag monitor.

 

(Example of table data)

c_action_0162

 

(Example written on tag)
c_action_0163

 

 

Setup Procedure

Tag configuration

 

1.Set tags.
 
c_action_0153

 

Tag Name

address

the purpose

U01.F01.T01

X0000

A tag that triggers an action

U01.F01.D0000~D0009

D0000 to D0009

Tags to be written in bulk

 

 


Action Settings

 

1.Register the Batch transfer (ODBC → Tag) action "A01".
 
c_action_0154
 

2.Add a field to A01.
 
Drag and drop the tag into A01. This action allows you to register tags simply by dragging and dropping them.
 
c_action_0034
 
Field created.
 
c_action_0156
 
 

3.Batch transfer (ODBC → Tag) Action property settings and table creation
 

Create the target table in the database.

In this example, a table is created with the following contents:

 

Table name: BATCH_TABLE

 

Key field name: BATCH_NAME

Value field name: BATCH_VALUE

 

(Field setting example for SQLServer2017)

c_action_0158

 

The recommended data types for each connectable DBMS are described in "Database connection settings" in Appendix.

 

Next, set up the ODBC data source from the Batch transfer tab of the action. The ODBC setting procedure can be performed using the same operations for each ODBC. For ODBC settings, please refer to the description in "ODBC Settings" in the common settings of the action.

 

In this example, the data source is defined with the name "BATCH_ODBC_TAG", and the table name to connect to is specified as "BATCH_TABLE" created above.

 
When setting the input data, set the name of the field on the database side that you want to match.

 
c_action_0157
 
 

4.Writes a key value into a key field.
 
From the Batch transfer tab, click the "Generate Master Record" button to write the key batch name to the database.
 
c_action_0159
 

The following screen shows the batch name correctly written to the database (an example for SQLServer2017).

 
c_action_0160

 

 


Event Settings

 

1.Create a Tag event to perform the action.

 

In this example, we will set the event to occur when U01.F01.T01 becomes TRUE.

 
c_action_0132

 
Set the execution action to "A01".
 
c_action_0365