Ways to store data

Hi,
I’m asking some suggestions from you regarding the ways to store time based record data. Basically I have to record parameters from 10 machines every 5 seconds. Those parameters are the same for all machines in a manner like:

Machine1, Par1, Par2, Par3, ParN
Machine2, Par1, Par2, Par3, ParN
MachineN, Par1, Par2, Par3, ParN

I’ve setup a Block Transaction group and it works fine but sometimes happen that one of that machine is stopped and I don’t want to record it. With Block Group i can’t say to not record data from a specific set and at the same time I wouldn’t to create a Standard Group per each machine. Should I have to use the Tag History and control the history feature through it? Machine tags are linked to a Data Type.

Thank you for your suggestions.

Davide Bortolini

Hi dbortolini,

I have a couple ideas. One idea is to add an expression item to your transaction group that deletes rows from stopped machines. You would need one of the tags/columns to represent if a machine is stopped or not. That way your DELETE SQL query could use that column to determine which rows to delete. Using this method you would still be logging rows from stopped machines but they would be automatically deleted.

Another possible way to implement what you are trying to do is write a Gateway Event Script that logs the appropriate data. You could execute SQL insert queries in your Python script with the system.db.runSFPrepUpdate function and they would go through the store and forward system.

Best,

In addition to Nick’s suggestions, also look at the use of triggers in your database. A PostgreSQL “Before Insert” trigger function can return NULL to skip an insert, and MS SQL Server’s “Instead Of Insert” trigger can return without actually inserting. Oracle can also do this, but you must set up an “Instead Of Insert” trigger on a VIEW, which then diverts good records to the actual table.