Insert records in the tavke only if they are not exist

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Insert records in the tavke only if they are not exist
Date: 2024-12-07 03:36:40
Message-ID: CA+FnnTwcNNGsM_ck0ye1OsUN3Jjg94PzGMKRm--2ojJM_zVOMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, All,

When my application starts up, ot creates some tables and insert records in
them.

When the app starts for the second time it should check if the tables and
the records in them are exist and skip the process.

Everything is good, except what if I have a connection from 2 different
users?

I can run this inside transaction, but will this be enough? Will stating
transaction lock the DB and the second user will wait for transaction to
complete?

Thank you.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2024-12-07 03:55:00 Re: Insert records in the tavke only if they are not exist
Previous Message Michel Pelletier 2024-12-07 00:51:50 Re: Using Expanded Objects other than Arrays from plpgsql