Re: [GENERAL] get the previous assigned sequence value
От | Ross J. Reedstrom |
---|---|
Тема | Re: [GENERAL] get the previous assigned sequence value |
Дата | |
Msg-id | 19991209103532.B6311@rice.edu обсуждение исходный текст |
Ответ на | Re: [GENERAL] get the previous assigned sequence value ("Dev Elop" <dev@archonet.com>) |
Список | pgsql-general |
Gah, this is getting a bit annoying, correcting this bit of mis-information. currval() is kept as part of the session context, as is completely multi-user safe. That's why the person you quoted said 'in the same session'. Where is everyone coming up with the wrong idea on this? Is there a major commercial DB with sequence objects that gets this wrong? Ross -- Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> NSBRI Research Scientist/Programmer Computer and Information Technology Institute Rice University, 6100 S. Main St., Houston, TX 77005 On Thu, Dec 09, 1999 at 10:36:40AM -0000, Dev Elop wrote: > > > > > > After an INSERT, I want to retrieve the value of the sequence I use for > > > unique_ids > > > > ... > > > > Alternatively, use the currval(mytable_id_seq) function within the same > > session immediately after the insert. > > > With this second method, you'd probably need to beware race conditions. If > another process inserts a record into mytable after you do but before you > call currval(), then you'll get the wrong value. > > Not an issue if you've only got one process accessing the table - probably > is one if you have two or more. > > - > Richard Huxton > > > ************ >
В списке pgsql-general по дате отправления: