![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
How about SELECT nextval('seq'); -- ignore result INSERT INTO ... VALUES (currval('seq'), currval('seq')); |
#2
| |||
| |||
|
|
"PostgreSQL Bugs List" <pgsql-bugs (AT) postgresql (DOT) org> writes: /* this statement will reverse the order of CURRVAL()/NEXTVAL() to match the column order of the table */ INSERT INTO testing (col_b, col_a) VALUES (NEXTVAL('seq'), CURRVAL('seq')); This is not a bug. The order of evaluation of select-lists and values-lists is not defined anywhere in the SQL standard, nor promised anywhere in the Postgres documentation. Thanks for the clarification. I am curious, however: I can't find a |
#3
| |||
| |||
|
|
Tom Lane wrote: How about SELECT nextval('seq'); -- ignore result INSERT INTO ... VALUES (currval('seq'), currval('seq')); Well, it works for my sample case, I have to agree. Maybe I should mention that I tried to boil down the bugreport to the simplest repro case I could. My actual SQL looks roughly like INSERT INTO destination (record_id, page, row) SELECT (SELECT record_id FROM record ORDERED BY name), (NEXTVAL('seq') / 200), (CURRVAL('seq') % 200) While I have a workaround, I am definitely curious as to whether there is actually a way to do it. Thanks for your patience. |
![]() |
| Thread Tools | |
| Display Modes | |
| |