Re: Can I do this?

From: Justin <zzzzz(dot)graf(at)gmail(dot)com>
To: Michael Nolan <htfoot(at)gmail(dot)com>
Cc: stan <stanb(at)panix(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Can I do this?
Date: 2020-01-16 16:38:15
Message-ID: CALL-XeNps-P__HAfd8=97yjernpvWe0QN2ZVcJU20dBCLqyrkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

it does not, but the odds the same user will run this command by this id
in two different sessions at the same time are very low.

this type of code exist for PO,SO, Invoices, to assign the next line item
# in many apps.

On Thu, Jan 16, 2020 at 10:40 AM Michael Nolan <htfoot(at)gmail(dot)com> wrote:

>
>
> On Thu, Jan 16, 2020 at 6:28 AM stan <stanb(at)panix(dot)com> wrote:
>
>> I am trying to create a function to automatically create a reference value
>> when a record is inserted into a table. I want the reference value to
>> consist of the user that is doing the insert, plus a couple of dates, plus
>> a sequence number, where the sequence number will increment every time a
>> given user inserts a record. because this sequence number is user
>> specific,
>> my first thought is not to use a set of sequences for it, but to do this
>> by
>> selecting the maximum sequence number that user has entered in the past.
>>
>> What happens if two transactions by/for the same user are committed at
> around the same point in time? The advantage of sequences is they're
> guaranteed to be unique, I'm not sure counting the number of previous
> records and adding one will always assure that.
> --
> Mike Nolan
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-01-16 16:49:54 Re: Re-2: Problem with SqlState=23505 when inserting rows
Previous Message Adrian Klaver 2020-01-16 16:17:13 Re: Is there a GoTo ?