Re: currval() without specifying the sequence name

From: Richard Huxton <dev(at)archonet(dot)com>
To: ow <oneway_111(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: currval() without specifying the sequence name
Date: 2004-03-09 15:14:56
Message-ID: 200403091514.56649.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tuesday 09 March 2004 13:50, ow wrote:
> Hi,
>
> Is there a way to retrieve the current value (i.e. the last used value) of
> the last used sequence without specifying the sequence name? Something like
> the following:
>
> create table ( id serial, value varchar(10));
> insert into someOthertest (value) values ('100');
> insert into test (value) values ('10');
> insert into test (value) values ('20');
>
> select currval() should returns 2 (the last value of the test table
> sequence)

Not really - what if two sequences had been used?

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Boes 2004-03-09 15:17:12 Re: Dramatic slowdown of sql when placed in a function
Previous Message Achilleus Mantzios 2004-03-09 15:09:47 Re: currval() without specifying the sequence name