Search Postgresql Archives

Re: currval() in insert statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Onno Molenkamp wrote:
> Hi,
> 
> 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's generally a REALLY bad idea to mix `nextval' and `currval' use on
the same sequence in a single SQL statement.

Personally, in the one case in the project I'm working on where I DO
need to INSERT a generated ID in two places I use a trigger to take care
of it.

--
Craig Ringer

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux