Search Postgresql Archives

Re: WITH x AS (...) and visibility in UPDATE

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

 



On 7/27/2011 4:22 PM, Peter V wrote:
I want to apply updates on a copy of a row, instead on the row itself. The queries are above were simplied to demonstrate the problem.
So basically I want to do:

1) create the copy of the row and return the identifier
2) apply updates on the new row identified by the identifier returned in step 1

If possible, I want to write this in a single command, to avoid overhead and mistakes.

I tried writing a rewrite rule or before trigger, but it becomes quickly a mess to avoid infinite loops.

Any ideas are welcome. Thanks.
  		 	   		
Maybe I'm totally missing something, but why insert a copy and then update instead of directly insert a mutated copy?

Something like:
INSERT INTO t (foo, bar) SELECT 'my new foo', t.bar FROM t WHERE id=123;

Wouldn't the above construction let you make a new row with some new values and some copied values?

--
Jack Christensen
jackc@xxxxxxxxxxxxxxxxx


--
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