Re: problem fetching currval of sequence - Mailing list pgsql-sql

From Josh Berkus
Subject Re: problem fetching currval of sequence
Date
Msg-id web-1602018@davinci.ethosmedia.com
Whole thread Raw
In response to problem fetching currval of sequence  (Charles Hauser <chauser@duke.edu>)
Responses Re: problem fetching currval of sequence  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: problem fetching currval of sequence  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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




pgsql-sql by date:

Previous
From: Joerg Hessdoerfer
Date:
Subject: Re: Table design question...
Next
From: Stephan Szabo
Date:
Subject: Re: problem fetching currval of sequence