From: | Rob Sargent <robjsargent(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Uniform UPDATE queries |
Date: | 2012-04-19 18:32:15 |
Message-ID: | 4F905A2F.7080205@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(dot)verbeek(at)victorem(dot)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)?
From | Date | Subject | |
---|---|---|---|
Next Message | John Fabiani | 2012-04-23 14:28:56 | getting the OS user name |
Previous Message | Pavel Stehule | 2012-04-19 11:58:13 | Re: plpgsql : adding record variable to table |