Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Automatically update sequence



On Friday 28 March 2008, Ognjen Blagojevic <ognjen(at)etf(dot)bg(dot)ac(dot)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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group