Re: problem fetching currval of sequence

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Charles Hauser <chauser(at)duke(dot)edu>, pgsql-sql(at)postgresql(dot)org
Subject: Re: problem fetching currval of sequence
Date: 2002-08-06 15:45:45
Message-ID: web-1602018@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Charles,

> I have a script to load values into a table (gb) which contains a
> SEQUENCE ('gb_id'). For each entry into TABLE gb I need the value of
> 'gb_gb_id_seq' to update a relational table. I am getting the
> following error msg:
> ERROR: gb_gb_id_seq.currval is not yet defined in this session.

Sometime in the upgrade process for 7.1.0 --> 7.2.1, the CURRVAL
function changed so that it was rigorously session-specific. I can see
a number of good reasons for doing this, but it has the unfortunate
side effect that CURRVAL is virtually useless for querying the current
value of the row you just inserted using a front-end that creates a new
session for each command.

I'd love to hear Tom, Bruce, or Stephan's comments on the issue. It is
an annoyance, and it would be nice to know the reason for the decrease
in functionality of CURRVAL.

All that aside, the first query you are sending to Postgres is an
UPDATE query, not an INSERT. So what good was CURRVAL going to do you
anyway?

-Josh Berkus

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2002-08-06 15:57:41 Re: problem fetching currval of sequence
Previous Message frederic massot 2002-08-06 15:29:16 SQL syntax