Re: Last ID Problem

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Last ID Problem
Дата
Msg-id 20050504165626.GB30968@wolff.to
обсуждение исходный текст
Ответ на Re: Last ID Problem  (<operationsengineer1@yahoo.com>)
Список pgsql-novice
On Wed, May 04, 2005 at 09:21:52 -0700,
  operationsengineer1@yahoo.com wrote:
> > Why not first get the current value from the
> > sequence, use it for your
> > INSERT statement, and then have it handy for the
> > rest of the script?
>
> i hate to revisit this old topic, however, i just want
> to make sure i'm avoiding future problems.
>
> if i pull nextval then insert it into the id column
> where i pulled it from, will the counter ever get "off
> track" since i'm doing manual inserts?

What do you mean by off track? nextval will return a unique value each
time it is called. If you want to refer to the last value returned by
nextval in the same session, you should use currval.

> can nextval ever become a value that's unexpected?  in
> practice, this method is working very well, but i'm
> paranoid.  ;-)

When you reach the maximum value for the sequence then you will get an
error. The default maximum value for 8.0 appears to be 9223372036854775807.
If you store the value in a 4 byte integer, then you will have problems
sooner.

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

Предыдущее
От:
Дата:
Сообщение: Re: Last ID Problem
Следующее
От: "sZEJTAN"
Дата:
Сообщение: date update check