From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Roy Souther <roy(at)SiliconTao(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Insert race hazard condition. |
Date: | 2003-03-25 20:10:05 |
Message-ID: | 20030325120530.B43277-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 25 Mar 2003, Roy Souther wrote:
> First of all I am a programmer not an DBA expert.
>
> There seems to be many ways to solve this. My first idea would be if I
> could make the INSERT some how return the index+1 that it creates but I
> can not find any way to make that work.
>
> My current idea is to have a short function that does both steps then
> returns the index value. This works and I think it should not cause any
> race hazard because the SQL execution should be completed before it
> returns to the program.
I think that it won't be guaranteed to work unless you lock the table.
> Is there a better way to do this? How do DBAs with a lot of connections
> safely create new records?
You might want to look at using a sequence to do your number generation.
From | Date | Subject | |
---|---|---|---|
Next Message | patrick | 2003-03-25 20:32:03 | Re: Insert race hazard condition. |
Previous Message | Bruno Wolff III | 2003-03-25 20:07:59 | Re: Insert race hazard condition. |