#793

Same shipment receipt, modern syntax

Same shipment-receipt scenario: an item arrived — if it's already in inventory, add to its quantity and refresh updated_at; if not — create a new row. Postgres 15 and up offers a more expressive syntax that packs both branches («matched» and «not matched») into a single statement. Extra warehouse rule: adding to an existing item is only allowed if the resulting stock stays at most 50 — the warehouse physically doesn't fit more.

Just INSERT/UPDATE/DELETE — no trailing SELECT needed.

Your query result will appear here