Idempotent Insert
Medium
Transactions & Concurrency
A payment callback may be delivered twice with the same txn_id. Write an INSERT that stores the payment once and silently ignores the duplicate.
Table schema
Payments(txn_id VARCHAR(20) PRIMARY KEY, amount INT)Sample data
Statement executed twice: insert ('T100', 500)
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.