# Skip failed DB inserts jython suggestions

**URL:** <https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795>\
**Category:** Ignition\
**Created:** [May 28, 2025, 9:49pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795 "2025-05-28T21:49:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 28, 2025, 9:49pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795/1 "2025-05-28T21:49:06Z")

</div>

I have a bunch of updates I am doing to a bunch of tables, some tables already have the updates completed so when I try to run the update statement it's throwing an error. The error is good so know I don't have to perform the update.

So my question is, since the updates have already been completed, I don't mind that the sql inserts have failed and I can skip them.

With that being said, is it bad practice to add a try catch and just do nothing in the except block and commit the transactions when the failed update occurs or is there a better/cleaner way to do it? Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 28, 2025, 9:59pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795/2 "2025-05-28T21:59:03Z")

</div>

The most efficient method is to have the DB intelligently throw the duplicate in the bit bucket on the floor without troubling the caller. I recommend using the `ON CONFLICT` clause in PostgreSQL.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 28, 2025, 10:00pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795/3 "2025-05-28T22:00:07Z")

</div>

I'm using mssql, I'll check and see if they have an on conflict. Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 28, 2025, 10:01pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795/4 "2025-05-28T22:01:47Z")

</div>

It didn't last I checked. It has a similar MERGE statement, IIRC, but it isn't deterministic in busy tables.

(It really helps to have a competent database.)

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 28, 2025, 10:17pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795/5 "2025-05-28T22:17:15Z")

</div>

Tell that to the company I work for! haha thanks again

I was just reading up on merge

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 28, 2025, 10:57pm UTC](https://forum.inductiveautomation.com/t/skip-failed-db-inserts-jython-suggestions/106795/6 "2025-05-28T22:57:02Z")

</div>

Watch out for side effects in other DBs that make the alternatives not truly equivalent to the SQL Standard's ON CONFLICT.
