Re: Automatically update sequence

Поиск
Список
Период
Сортировка
От Alan Hodgson
Тема Re: Automatically update sequence
Дата
Msg-id 200803280935.56295@hal.medialogik.com
обсуждение исходный текст
Ответ на Automatically update sequence  (Ognjen Blagojevic <ognjen@etf.bg.ac.yu>)
Ответы Re: Automatically update sequence  (Ognjen Blagojevic <ognjen@etf.bg.ac.yu>)
Список pgsql-novice
On Friday 28 March 2008, Ognjen Blagojevic <ognjen@etf.bg.ac.yu> wrote:
> Here, I used literal value for ID (1000), and I want my sequence to be
> updated to 1000 automatically (i.e. without calling setval).

You could probably use a trigger to do it, but it's not a great idea.

What you should do is fetch the next value from the sequence yourself and
then use it in the insert. Or, if you're pre-loading existing data, load it
and then set the sequence value afterwards.

--
Alan

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

Предыдущее
От: "Sean Davis"
Дата:
Сообщение: Re: Automatically update sequence
Следующее
От: Ognjen Blagojevic
Дата:
Сообщение: Re: Automatically update sequence