Re: currval() in insert statements

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: currval() in insert statements
Дата
Msg-id 3051.1234629665@sss.pgh.pa.us
обсуждение исходный текст
Ответ на currval() in insert statements  (Onno Molenkamp <onno@flox.org>)
Список pgsql-general
Onno Molenkamp <onno@flox.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: trigger creation error (tsvector_update_trigger)
Следующее
От: Carlos Henrique Reimer
Дата:
Сообщение: Track a function