Re: how to make an SQL UPDATE from record returning function - Mailing list pgsql-general

From Rafal Pietrak
Subject Re: how to make an SQL UPDATE from record returning function
Date
Msg-id 1335342503.12061.12.camel@localhost.localdomain
Whole thread Raw
In response to Re: how to make an SQL UPDATE from record returning function  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
On Tue, 2012-04-24 at 12:10 +0200, Thomas Kellerer wrote:
> Rafal Pietrak, 24.04.2012 09:02:
> >
> > is not an option, since the function is *very* expensive (multiple join
> > of large tables - inventories, history, etc).
> >
> > Is there a syntax workaround that I could possibly use to get the effect
> > of launching my_function just once?
>
> With 9.1 you could probably achieve this using a writeable CTE.
>
> Although I have to admit I don't really understand what your function is returning.
> Does the function return a result set or scalar values?
>

Basically, it's at shopping cart update.

It ranks updated an item with costommer rating of that item with respect
to other orders and current stock (so that when the cart is only
presented, the values are there, precomputted on update). There is more
then one value to precompute, so the function returns a set of values.
(earlier I only needed to precompute just one value and everything was
so easy then... :).

Could you pls give me an example of how the "writeable CTE"? This does
not ring a bell here.


-R


pgsql-general by date:

Previous
From: Willy-Bas Loos
Date:
Subject: Re: Bug? Query plans / EXPLAIN using gigabytes of memory
Next
From: hari.fuchs@gmail.com
Date:
Subject: Re: how to group by similarity ?