Skip site navigation (1) Skip section navigation (2)

Re: Reuse temporary calculation results in an SQL update query

From: Andreas Kretschmer <andreas(at)a-kretschmer(dot)de>
To: Matthias Nagel <matthias(dot)h(dot)nagel(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Reuse temporary calculation results in an SQL update query
Date: 2012-09-29 10:56:35
Message-ID: 1237868969.148407.1348916195838.JavaMail.open-xchange@ox.ims-firmen.de (view raw or flat)
Thread:
Lists: pgsql-sql

Matthias Nagel <matthias(dot)h(dot)nagel(at)gmail(dot)com> hat am 29. September 2012 um 12:49
geschrieben:
> Hello,
>
> is there any way how one can store the result of a time-consuming calculation
> if this result is needed more than once in an SQL update query? This solution
> might be PostgreSQL specific and not standard SQL compliant. Here is an
> example of what I want:
>
> UPDATE table1 SET
>    StartTime = 'time consuming calculation 1',
>    StopTime = 'time consuming calculation 2',
>    Duration = 'time consuming calculation 2' - 'time consuming calculation 1'
> WHERE foo;

The Duration - field is superfluous ...

As far as i know there is no way to re-use the result.


Regards, Andreas


In response to

Responses

pgsql-sql by date

Next:From: Matthias NagelDate: 2012-09-29 11:04:23
Subject: Re: Reuse temporary calculation results in an SQL update query
Previous:From: Thomas KellererDate: 2012-09-29 10:55:39
Subject: Re: Reuse temporary calculation results in an SQL update query

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group