Re: currval() in insert statements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Onno Molenkamp <onno(at)flox(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: currval() in insert statements
Date: 2009-02-14 16:41:05
Message-ID: 3051.1234629665@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Onno Molenkamp <onno(at)flox(dot)org> writes:
> I recently upgraded a database from 8.1.11 to 8.3.6, and I noticed the
> following statement stopped working:
> insert into test (b) select currval('test_a_seq'::regclass)

It doesn't work in 8.1 either:

Welcome to psql 8.1.16, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

regression=# create table test (a serial, b int);
NOTICE: CREATE TABLE will create implicit sequence "test_a_seq" for serial column "test.a"
CREATE TABLE
regression=# insert into test (b) select currval('test_a_seq'::regclass);
ERROR: currval of sequence "test_a_seq" is not yet defined in this session
regression=#

There must be something else that you changed about your application.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2009-02-14 16:49:59 Re: Track a function
Previous Message Tom Lane 2009-02-14 16:36:09 Re: trigger creation error (tsvector_update_trigger)