Re: [GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-11 Thread David Johnston
Aleksandr Furmanov wrote > Thanks, > However I am not just replicating data from 'a' to 'b', I provided > simplified example, in reality table 'b' keeps data which are going to be > merged into 'a', some rows will be updated, some added. There is some > other work has to be done on 'b' before mergi

Re: [GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-10 Thread Aleksandr
Thanks, However I am not just replicating data from 'a' to 'b', I provided simplified example, in reality table 'b' keeps data which are going to be merged into 'a', some rows will be updated, some added. There is some other work has to be done on 'b' before merging into 'a' and that work relies

Re: [GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-10 Thread Richard Dunks
If you're just replicating the data from table A into table B, why does it need its own ID number? Wouldn't the table A ID suffice? I'd recommend using the following: CREATE TABLE b AS ( SELECT * FROM a ); This way, you only define the columns and insert the data once, then let Postgres do the

[GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-10 Thread Aleksandr Furmanov
Hello, I want to insert new values into target table 'a' from source table 'b', and then update table 'b' with ids from table 'a', somewhat like: CREATE TABLE a(id SERIAL, name TEXT); INSERT INTO a (name) VALUES('Jason'); INSERT INTO a (name) VALUES('Peter'); CREATE TABLE b(row_id serial, id INT