its posible to use a 2 column returning function as a subquery?

From: Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar>
To: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: its posible to use a 2 column returning function as a subquery?
Date: 2009-09-11 20:16:30
Message-ID: 4AAAB01E.8070009@fmed.uba.ar
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All. My poor english doest not allow me to get a better subject.
Here is the thing: I have a function who returns a two column result,
that is is used inside another function, like this

CREATE FUNCTION show_result((some args), OUT shoe varchar, OUT desc
varchar , OUT price numeric)
...
as
$$
select shoe,
(get_desc_and_price(shoe)).desc,
(get_desc_and_price(shoe)).price
from ...
$$ language sql;

This is the only way i get this thing working. According to the timming,
it looks like get_desc_and_price() is being called twice. There is some
syntax for calling get_desc_and_price only once?
As getting the 'description' and the 'price' share most of the logic, it
looks ok to write a single function that does the job.

Thanks!
Gerardo

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2009-09-11 21:44:54 Re: its posible to use a 2 column returning function as a subquery?
Previous Message Gerardo Herzig 2009-09-11 18:14:17 Re: about pg_proc (column pronamespace)