From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: Charles Hauser <chauser@duke.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: problem fetching currval of sequence
Date: Tue, 06 Aug 2002 16:18:45 -0400
Message-ID: <2971.1028665125@sss.pgh.pa.us> (raw)
In-Reply-To: <200208061135.20799.josh@agliodbs.com>
References: <web-1602018@davinci.ethosmedia.com>
<20611.1028651144@sss.pgh.pa.us>
<200208061135.20799.josh@agliodbs.com>
Josh Berkus <josh@agliodbs.com> writes:
> No, back in 7.1.0 I was able to call CURRVAL without having previously
> called NEXTVAL, and it would give me the "current" sequence value;
> that is, the same result value as (NEXTVAL() - 1)
I don't believe it, and neither do the 7.1.3 and 7.0.2 databases that
I have handy to check with. For example:
play=> select version();
version
------------------------------------------------------------------
PostgreSQL 7.0.2 on hppa2.0-hp-hpux10.20, compiled by gcc 2.95.2
(1 row)
play=> create sequence seq;
CREATE
play=> select currval('seq');
ERROR: seq.currval is not yet defined in this session
play=> select nextval('seq');
nextval
---------
1
(1 row)
play=> select currval('seq');
currval
---------
1
(1 row)
play=> \c play
You are now connected to database play.
play=> select currval('seq');
ERROR: seq.currval is not yet defined in this session
Are you sure you were not thinking of "select last_value from seq"?
That's about the closest approximation I can think of to a
non-transaction-safe version of currval().
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, chauser@duke.edu
Subject: Re: problem fetching currval of sequence
In-Reply-To: <2971.1028665125@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox