From: | "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov> |
---|---|
To: | "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>, "Oliver Fromme" <olli(at)lurza(dot)secnetix(dot)de> |
Cc: | "Michael Glaesemann" <grzm(at)myrealbox(dot)com>, <pgsql-novice(at)postgresql(dot)org>, "A Gilmore" <agilmore(at)shaw(dot)ca> |
Subject: | Re: Design question regarding arrays |
Date: | 2004-08-09 14:34:35 |
Message-ID: | 000401c47e20$83fb1520$04653744@WATSON |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
That is exactly what I had in mind but wasn't clear on.
Sean
----- Original Message -----
From: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>
To: "Oliver Fromme" <olli(at)lurza(dot)secnetix(dot)de>
Cc: "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov>; "Michael Glaesemann"
<grzm(at)myrealbox(dot)com>; <pgsql-novice(at)postgresql(dot)org>; "A Gilmore"
<agilmore(at)shaw(dot)ca>
Sent: Monday, August 09, 2004 10:22 AM
Subject: Re: [NOVICE] Design question regarding arrays
> On Mon, 9 Aug 2004, Oliver Fromme wrote:
>
> > Sean Davis wrote:
> > > I'm a novice, too, but why not look up the value in the sequence and
> > > increment it before doing any inserting? If you are doing all the
inserts
> > > at the same time (more or less), then you can just use this value in
the
> > > insert into both tables. Put all of this inside one transaction.
> >
> > That won't work if another process is trying to do the same
> > thing at the same time. They both get the same value when
> > they look it up, so there will be an ID collision.
>
> It should be safe if you're using a sequence and using nextval() to get
> the value that you are using in both insert statements. A second session
> will not get the same value you just got from nextval barring a cycling
> sequence generator that wraps back to the same number between the nextval
> and insert.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Tucknott | 2004-08-09 15:15:56 | Re: Multiple return 'columns' from postgre pl/pgsql |
Previous Message | Tom Lane | 2004-08-09 14:23:11 | Re: Multiple return 'columns' from postgre pl/pgsql |