Data · 2026
ERP sync that stops failing
Nightly jobs that copy master data from an ERP kept failing on real-world data. I rebuilt them to cope with it.
The problem
Every record came with an instruction to insert, update or delete, and the jobs followed it blindly. But the ERP sends records twice, out of order, or for rows that don't exist yet. Each mismatch became a failed row that someone had to fix by hand.
What we did
- 01
If a record marked "insert" already exists, update it. If a record marked "update" is missing, insert it.
- 02
The right matching key for each table, including combined keys and matching on either login ID or email, so duplicates don't creep in.
- 03
Protected columns, so values we calculate ourselves and audit fields don't get overwritten.
- 04
Empty fields in an update are ignored, so they don't wipe out good data.
How it turned out
The action field became intent, not instruction. After each run the data matches the ERP, and nobody has to fix rows by hand.