Re: [GENERAL] RE: [GENERAL] INSERT. RETURNING for copying records

2012-09-08 Thread dinesh kumar
Hi David, I am not sure the RETURNING offers you the following behavior .. What I'm looking for +--+-+ | original_rid | rid | +--+-+ | 1| 4 | | 2| 5 | | 3| 6 |

Re: [GENERAL] RE: [GENERAL] INSERT. RETURNING for copying records

2012-09-08 Thread David Johnston
Maybe: Where newvals AS () , insertval AS (insert...select...from newvals) #NO RETURNING Select * from newvals I believe the insertval CTE is guaranteed to run even if not directly involved with the main select statement. David J. On Sep 8, 2012, at 2:33, dinesh kumar dineshkuma...@gmail.com

[GENERAL] Re: [GENERAL] INSERT… RETURNING for copying records

2012-09-08 Thread Misa Simic
You can make function what returns integer and has input parametars as other columns of the table: INSERT INTO testing (category, name, fk_parent) (input parameters) returning rid Then SELECT rid as OriginalId, make_copy(other columns) as new_rid From testing Kind Regards, Misa On Friday,

[GENERAL] RE: [GENERAL] INSERT. RETURNING for copying records

2012-09-07 Thread David Johnston
From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Michael Sacket Sent: Friday, September 07, 2012 2:09 PM To: PG-General Mailing List Subject: [GENERAL] INSERT. RETURNING for copying records Good Afternoon, I'm attempting to write a