Re: [GENERAL] currval() in insert statements

2009-02-15 Thread Craig Ringer
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 sequenc

Re: [GENERAL] currval() in insert statements

2009-02-14 Thread Tom Lane
Onno Molenkamp 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. Typ

Re: [GENERAL] currval() in insert statements

2009-02-14 Thread Raymond O'Donnell
On 14/02/2009 11:25, Onno Molenkamp wrote: > 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) I don't think this was ever guaranteed to work - the docs say pretty clearl

Re: [GENERAL] currval() in insert statements

2009-02-14 Thread Onno Molenkamp
Hi, I know that, and nextval -is- being called because it's the default value of column "a". The problem is that apparently the order in which it's called has changed for the form with a select, not that I don't know the difference between currval and nextval. Onno Op Saturday 14 February 200

Re: [GENERAL] currval() in insert statements

2009-02-14 Thread Grzegorz Jaƛkiewicz
nextval. currval only has value, when sequence wwas used in the session before, you would use it to obtain last value returened by nextval. read the manual . On Sat, Feb 14, 2009 at 11:25 AM, Onno Molenkamp wrote: > Hi, > > I recently upgraded a database from 8.1.11 to 8.3.6, and I noticed the >

[GENERAL] currval() in insert statements

2009-02-14 Thread Onno Molenkamp
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) given the following table: create table test (a serial, b int) The error I'm getting is: "ERROR: currval of sequence