This lesson is part of the Transaction Groups in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off
Take topic challenge

Description

See an example of how to create a Transaction Group that updates a row in the database based on an ID. Because of the "Insert row when not present" setting, the group will insert a new record whenever the current ID doesn't already exist.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] Transaction groups are normally used to insert or update a particular row in a database table. However, it's also possible to use them in a manner that will update a row or insert a new row if a specified key combination is not present. So for example, we could create a new standard group and bring in some tags that represent the current values of a particular batch. To get the table created, we'll give it a name, and I'll enable it one time set to update the first row, just to create all of the columns. With that done, I can pause the group, and I'll set the batch ID to be read-only, because we want to use it in our where clause. But we don't necessarily need to write new data to that column. Back in the table action section, we'll select key value pairs.

[01:04] This is where we'll map the column batch ID to a value, in this case, the batch ID tag. Now we'll select this option below that says insert row when not present. This option works with any number of parameters in the key value pair table. So you can have multiple dynamic values, and the group will insert a new row any time any of the values have changed. We'll see it in action with a single value. Now we can run the group and take a look at the database table. We'll see that there's one row inserted for our batch ID zero, and it is constantly updating with the new values from the tags. If we modify our batch ID tag value, a new row will be inserted on the next execution, and it will become the target of the following values. This simple example shows how you can create a group that can dynamically track part numbers, batch numbers, barcodes, or anything where you have dynamic values associated with a changing ID.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.