Re: Insert records in the tavke only if they are not exist

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Igor Korot <ikorot01(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Insert records in the tavke only if they are not exist
Date: 2024-12-07 03:55:00
Message-ID: CAKFQuwZmv_R-v5050iF9YynOPqzEzi8atj_w1Sjo6CaNBgZLPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday, December 6, 2024, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>
> 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?
>
>
Seems like letting the create table fail would be a reliable way to
determine what is happening. But this procedure overall just seems better
avoided. Can’t you just run an installer/updater separate from running the
application?

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2024-12-07 04:02:22 Re: Insert records in the tavke only if they are not exist
Previous Message Igor Korot 2024-12-07 03:36:40 Insert records in the tavke only if they are not exist