Re: HOWTO caching data across function calls: temporary tables, cursor?

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: HOWTO caching data across function calls: temporary tables, cursor?
Дата
Msg-id D960CB61B694CF459DCFB4B0128514C201ED2709@exadv11.host.magwien.gv.at
обсуждение исходный текст
Ответ на HOWTO caching data across function calls: temporary tables, cursor?  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Ответы Re: HOWTO caching data across function calls: temporary tables, cursor?  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Список pgsql-general
Ivan Sergio Borgonovo wrote:
> I've a bunch of functions that operates on the basket (a smaller list
> of products with their attributes).
>
> So many functions ends up in repeating over and over a select similar
> to:
>
> select [list of columns] from baskets b
> join basket_items bi on b.basket_=bi.basket_id
> join items i on i.item_id=bi.item_id
> join item_attributes a a.item_id=i.item_id
> where b.basket_id=$1
>
> It would be nice if I could avoid to execute this query over and over.
> I'd have to find a way to pass this data across functions.

You could pass arrays containing the selected rows between functions.
Something like:

CREATE TYPE basket_row AS(id integer, name text, count integer, ...);
CREATE FUNCTION sell (items basket_row[]) RETURNS boolean LANGUAGE plpgsql
   AS $$........$$;

Yours,
Laurenz Albe

В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Using tables in other PostGreSQL database
Следующее
От: "josep porres"
Дата:
Сообщение: minimum and maximum functions