Re: how to make an SQL UPDATE from record returning function

From: Rafal Pietrak <rafal(at)zorro(dot)isa-geek(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to make an SQL UPDATE from record returning function
Date: 2012-04-25 08:28:23
Message-ID: 1335342503.12061.12.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message hari.fuchs 2012-04-25 08:31:17 Re: how to group by similarity ?
Previous Message Willy-Bas Loos 2012-04-25 08:05:37 Re: Bug? Query plans / EXPLAIN using gigabytes of memory