Re: selecting a attribute from a function

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "A(dot)j(dot) Langereis" <a(dot)j(dot)langereis(at)inter(dot)nl(dot)net>
Cc: Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: selecting a attribute from a function
Date: 2005-11-30 04:37:39
Message-ID: 20051130043738.GA69148@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 24, 2005 at 11:47:53AM +0100, A.j. Langereis wrote:
> But how can I do something like this:
>
> select my_pg_func(table2.some_col).col1
> from table2.some_col

Use another set of parentheses around the function call, as at the
end of this example:

CREATE TYPE test_type AS (col1 integer, col2 integer);

CREATE FUNCTION test_func() RETURNS test_type AS $$
DECLARE
retval test_type;
BEGIN
retval.col1 := 123;
retval.col2 := 456;
RETURN retval;
END;
$$ LANGUAGE plpgsql;

SELECT * FROM test_func();
col1 | col2
------+------
123 | 456
(1 row)

SELECT (test_func()).col1;
col1
------
123
(1 row)

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-11-30 06:55:55 Re: Finding uniques across a big join
Previous Message Michael Fuhr 2005-11-30 04:30:45 Re: strange behaviour in plpgsql:null arguments