Re: Last inserted id

Поиск
Список
Период
Сортировка
От Geoffrey D. Bennett
Тема Re: Last inserted id
Дата
Msg-id 20011112192504.A3780@april.netcraft.com.au
обсуждение исходный текст
Ответ на Re: Last inserted id  (Dave Page <dpage@vale-housing.co.uk>)
Список pgsql-odbc
On Mon, Nov 12, 2001 at 08:23:08AM -0000, Dave Page wrote:
> > -----Original Message-----
> > From: Simeo Reig [mailto:simreig@terra.es]
> > Sent: 11 November 2001 22:54
> > To: Dave Page
> > Subject: Re: [ODBC] Last inserted id
> >
> >
> > I had think that the problem was this but I believed that
> > was possible to make a mistake because I'm newer with
> > ADO. What must I do ? I see two possibilities:
> >
> >  A) Make a select NEXTVAL from sequence, and
> >       insert this value in the id
> >
> >   B) Insert row and after make a CURRVAL
> >
> > What option Do you use ?
>
> Use option A), it's multi-user safe whereas the other method isn't.

Unless I'm missing something, option B _is_ multi-user safe.
currval() doesn't return the "current" value of the sequence (like
"select * from my_seq" would) -- it returns the last value that
nextval() gave that session (hence, it isn't defined until that
session does a nextval()).

I have no idea what ADO is :-), so there may be other issues here, but
I don't think multi-user access is one of them.

--
Geoffrey D. Bennett, RHCE, RHCX               geoffrey@netcraft.com.au
Senior Systems Engineer           http://www.netcraft.com.au/geoffrey/
NetCraft Australia Pty Ltd           http://www.netcraft.com.au/linux/

В списке pgsql-odbc по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Last inserted id
Следующее
От: Dave Page
Дата:
Сообщение: Re: Last inserted id