pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Order of Operations for Update Command
2+ messages / 2 participants
[nested] [flat]

* Order of Operations for Update Command
@ 2016-08-25 15:27 simonwhite@dciphercomputing.com
  2016-08-25 16:33 ` Re: Order of Operations for Update Command Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: simonwhite@dciphercomputing.com @ 2016-08-25 15:27 UTC (permalink / raw)
  To: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.5/static/sql-update.html
Description:

Does the Update command update the columns in the order they are listed? Can
an updated column&#39;s new value be used in the value calculation for a
subsequent column?
i.e. update mytable set qty=qty+5,price=price*1.1,subtotal=qty*price
Will the subtotal be calculated based on the old column values or the new
column values?

-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Order of Operations for Update Command
  2016-08-25 15:27 Order of Operations for Update Command simonwhite@dciphercomputing.com
@ 2016-08-25 16:33 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2016-08-25 16:33 UTC (permalink / raw)
  To: simonwhite@dciphercomputing.com; +Cc: pgsql-docs

simonwhite@dciphercomputing.com writes:
> Does the Update command update the columns in the order they are listed?

Notionally, they're all done concurrently.  This is embodied in our
docs by defining the update source expressions thus:

	An expression to assign to the column. The expression can use the
	old values of this and other columns in the table.

> Can an updated column's new value be used in the value calculation for a
> subsequent column?

No, see above.

			regards, tom lane


-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-08-25 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25 15:27 Order of Operations for Update Command simonwhite@dciphercomputing.com
2016-08-25 16:33 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox