0

I have a situation, where new patients can be created through multiple portals simultaneously.

I am working in PostgreSQL DB.

Thanks in Advance. VD.

Currently we are considering MAX(id) and incrementing by 1. However, if multiple users login simultaneously then both gets same MAX(ID), which is creating duplicate id issue.

Can someone suggest what's way to generate new id in this scenario?

2
  • 1
    Use an auto increment column, see the duplicate link. Commented Aug 24, 2023 at 13:57
  • Yes, MAX(id)+1 is a virtual guarantee you will get duplicates. Depending on you version redefine id to generated always as identity (v10 and later) or as serial/bigserial (v8 and later). See documentation here and here and phere](postgresql.org/docs/8.0/sql-createtable.html). Commented Aug 24, 2023 at 16:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.