Search Postgresql Archives

Re: Can I do this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> wrote:


On Thu, Jan 16, 2020 at 6:28 AM stan <stanb@xxxxxxxxx> 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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux