| From: | "Chris Travers" <chris(at)travelamericas(dot)com> | 
|---|---|
| To: | "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com>, <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: User-specific sequences... | 
| Date: | 2004-01-18 13:20:52 | 
| Message-ID: | 019101c3ddcd$78731cf0$8d285e3d@winxp | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martín Marqués | 2004-01-18 14:50:57 | Re: Automatic joins? | 
| Previous Message | Bill Seitz | 2004-01-18 12:55:26 | Re: massaging data from multiple timezones |