pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Uniform UPDATE queries
Date: Thu, 19 Apr 2012 12:32:15 -0600
Message-ID: <4F905A2F.7080205@gmail.com> (raw)
In-Reply-To: <4F8FEF2D.6050501@victorem.com>
References: <4F8E936A.9050303@victorem.com>
	<4420.1334766267@sss.pgh.pa.us>
	<4F8FEF2D.6050501@victorem.com>

On 04/19/2012 04:55 AM, Dennis wrote:
> Hello Tom,
>
> The example you have given is EXACTLY why something like CURRENT is
> needed to limit the number of unique queries or prepared statements. (or
> to do a selection of all values before an update meaning two executed
> queries.)
>
> regards,.
>
> Dennis
>
> On 04/18/2012 06:24 PM, Tom Lane wrote:
>> Dennis<dennis.verbeek@victorem.com> writes:
>>> When a query is written to update a table, the usual process is to
>>> list all the columns that need
>>> updating. This could imply the creation of many possible queries for
>>> many columns. In an effort to
>>> keep the UPDATE queries more uniform, less number of unique queries,
>>> a keyword similar to DEFAULT,
>>> let's say CURRENT, is required to indicate that the current value
>>> must not change.
>> No it isn't. Just write the name of the column, eg
>>
>> update mytable set x = x, y =<new value>, z = z where ...
>>
>> There's no reason to invent nonstandard syntax for this.
>>
>> regards, tom lane
>>
>>
>>
>
>


Not if you have all the old and new values:


update mytable set x= xval, y=yval, z=zval where yval happens to be a 
new value and xval, zval are current.

Seems your callers knows which have changed. Does it not know which have 
not (and what their values are)?



view thread (5+ messages)

Message-ID: <4F905A2F.7080205@gmail.com>
Permalink:  ../4F905A2F.7080205@gmail.com/
Also on:    postgresql.org/message-id/4F905A2F.7080205@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: robjsargent@gmail.com
  Subject: Re: Uniform UPDATE queries
  In-Reply-To: <4F905A2F.7080205@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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