Re: lastval(seq) ?

From: CSN <cool_screen_name90001(at)yahoo(dot)com>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: lastval(seq) ?
Date: 2003-10-21 19:49:39
Message-ID: 20031021194939.53464.qmail@web40612.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- "scott.marlowe" <scott(dot)marlowe(at)ihs(dot)com> wrote:
> On Mon, 20 Oct 2003, CSN wrote:
>
> > How do you get the last value of a sequence
> without
> > having called nextval? phppgadmin displays last
> value
> > for sequences (I haven't found out how yet rooting
> > through the code).
>
> First, the mandatory, why would you want to do that?

For updating sequences after copy importing data (with
id's).

select setval('table_id_seq', (select max(id) from
table));

vs.

select setval('table_id_seq', (select last_value from
table_id_seq));

Is there a transaction-safe way?

CSN

>
>
> Second: select last_value from table_id_seq;
>
> It's not transaction safe, so don't expect it to
> work right on busy
> multi-user systems.
>

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Michel POURE 2003-10-21 20:05:36 Re: DBDesigner for Linux
Previous Message Karsten Hilbert 2003-10-21 19:40:08 max() over some rows but grouped, within one view def - how ?