pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthias Nagel <matthias.h.nagel@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Reuse temporary calculation results in an SQL update query
Date: Sat, 29 Sep 2012 13:04:23 +0200
Message-ID: <1687060.cmZrQAXiMV@hek506> (raw)
In-Reply-To: <1237868969.148407.1348916195838.JavaMail.open-xchange@ox.ims-firmen.de>
References: <43516431.HfO3TYfNBy@hek506>
	<1237868969.148407.1348916195838.JavaMail.open-xchange@ox.ims-firmen.de>

Hello,

> Matthias Nagel <matthias.h.nagel@gmail.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 ...
> 

I expected the answer ;-), but no, it is not superfluous. In this small example it might appear as if it is, but there are cases in that the start time and the duration time have values and the stop time equals null to indicate a running session. And for reasons that are beyond the orginal question, there are also cases where duration does not equal the difference between start and stop time.

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

Too bad.

> Regards, Andreas

Thanks, Matthias

----------------------------------------------------------------------
Matthias Nagel
Willy-Andreas-Allee 1, Zimmer 506
76131 Karlsruhe

Telefon: +49-721-8695-1506
Mobil: +49-151-15998774
e-Mail: matthias.h.nagel@gmail.com
ICQ: 499797758
Skype: nagmat84





view thread (10+ messages)  latest in thread

Message-ID: <1687060.cmZrQAXiMV@hek506>
Permalink:  ../1687060.cmZrQAXiMV@hek506/
Also on:    postgresql.org/message-id/1687060.cmZrQAXiMV@hek506

 · 

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: matthias.h.nagel@gmail.com
  Subject: Re: Reuse temporary calculation results in an SQL update query
  In-Reply-To: <1687060.cmZrQAXiMV@hek506>

* 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