Multiple Records From Single Insert Query

We have had a couple of odd issues recently where it appears that we have had multiple records created in a SQL Server database from a single insert query coming from Ignition.

For example, we have a script that retrieves data from a table, and based on the contents of each record, it will create a separate record in another table. In 2 instances recently, we have found 2 records with the exact same timestamp (down to the ms) in the destination table, and we cannot find anything that would have caused the query to run twice on our end. We are using system.db.runPrepUpdate for this insert.

Also, it may be helpful to mention that the timestamp is set by using CURRENT_TIMESTAMP function in SQL Server.

If there is some sort of network disruption between Ignition and SQL Server, is there any chance that the command could be sent twice to SQL Server? I’m just looking for any insight into something I might be missing.

Any chance someone restored a .gwbk from your production system on a development system, but didn’t restore it disabled?

3 Likes

No, not in this case, but I appreciate the thought. One of the more perplexing aspects of this issue is the the timestamps. It appears that two or more records will go into the database at the exact same millisecond (which is very unlikely in our case), and then there will be a jump of several ms and it will happen again. For example, during a script that ran this morning, several inserts were grouped together at the same ms.

I don’t know for sure, but this might be happening on the SQL Server end since that is what actually controls the timestamp.

SQL Inserts

You’re script that has the system.db.runPrepUpdate - what triggers it? Is it atimer script, a tag change, etc?