Re: User-specific sequences... - Mailing list pgsql-general

From Chris Travers
Subject Re: User-specific sequences...
Date
Msg-id 019101c3ddcd$78731cf0$8d285e3d@winxp
Whole thread Raw
In response to User-specific sequences...  ("D. Dante Lorenso" <dante@lorenso.com>)
List pgsql-general
It would be nice if we had "Read Uncommitted" transaction level for this,
hint ;-).  In this scenario you will probably have to have your app check
for errors and retry if you get an abort.

I would do as follows:
create table widgets (
customer_id int references customers,
widget_id int
primary key (customer_id, widget_id)
);

Then I would have a trigger set to assign widget_id to (Select
max(widget_id) + 1 from widgets where customer_id = new.customer_id);

Then if by chance you have 2 duplicate submissions, you will get an error
you ned to handle in your app by retrying the insert.

Best Wishes,
Chris Travers



pgsql-general by date:

Previous
From: "Chris Travers"
Date:
Subject: Re: embedded/"serverless" (Re: serverless postgresql)
Next
From: Bill Moran
Date:
Subject: Using a Makefile during database development