Transaction group table select with multiple rows

Simple question, bit of a two-parter maybe. I have a transaction group, DB to OPC that selects from a table with a WHERE x=tag or y=tag clause. 99% of the time this will only return 1 row, but sometimes there may be 2 rows, how does this work when writing to the tags? Each selected row is written, last write wins? First row only? I could set my table name to a view and enforce a desired order there if need be to ensure the correct row is applied.

Second part, I also have this alternatively written as a gateway event script where I can deal with 0, 1, or 2 results, but coworkers looking at this after me are more familiar with transaction groups. Is it even worth trying to do this with a transaction group or just stick with the script?

Thank you

Undefined. If you cannot use a unique index corresponding to your WHERE clause columns, use ordering and LIMIT clause in a view.

Yes I can order the results, but what happens if I end up with two rows and write that to a group of tags? Testing with a view and ordered data it appears consistently that only first row is used, and this makes complete sense and it how I would assume it operates, but I was unable to find anything that definitively said this would be the case.

That's what undefined means. The observed behavior is an artifact of IA's implementation details and is not assured to continue in the future. Don't rely on undefined behavior.

1 Like