Thread: function return type is a setof some column type

function return type is a setof some column type

From
Murat Tasan
Date:
hi all, i'm new to the list, so if this is an off-topic question, or
has already been posed, i apologize...

i'm trying to figure out how to get the following test situation to
work:

creating a function like below fails...

CREATE FUNCTION test_function() RETURNS SETOF table.column%TYPE AS $$
SELECT 1; $$ LANGUAGE SQL;

yet i know the %TYPE format works because the below succeeds...

CREATE FUNCTION test_function() RETURNS table.column%TYPE AS $$
SELECT 1; $$ LANGUAGE SQL;

as does the SETOF option because the following also succeeds...

CREATE FUNCTION test_function() RETURNS SETOF int4 AS $$ SELECT 1; $$
LANGUAGE SQL;

can anyone help me figure out how to get the first function
declaration to work?
and yes, i know i could just look up the type of the column of
interest, but i'm trying to make the function somewhat independent of
table alterations (the whole reason for the %TYPE inclusion in
postgresql in the first place!)

thanks for any help!

murat

Re: function return type is a setof some column type

From
Murat Tasan
Date:
whoa.  sorry about this post.  i already posted this about 1 week
ago, and it's been resolved.  i have no clue why it is showing up
again on the list.

murat

On 30 Jan 2006, at 18:19, Murat Tasan wrote:

> hi all, i'm new to the list, so if this is an off-topic question,
> or has already been posed, i apologize...
>
> i'm trying to figure out how to get the following test situation to
> work:
>
> creating a function like below fails...
>
> CREATE FUNCTION test_function() RETURNS SETOF table.column%TYPE AS $
> $ SELECT 1; $$ LANGUAGE SQL;
>
> yet i know the %TYPE format works because the below succeeds...
>
> CREATE FUNCTION test_function() RETURNS table.column%TYPE AS $$
> SELECT 1; $$ LANGUAGE SQL;
>
> as does the SETOF option because the following also succeeds...
>
> CREATE FUNCTION test_function() RETURNS SETOF int4 AS $$ SELECT 1; $
> $ LANGUAGE SQL;
>
> can anyone help me figure out how to get the first function
> declaration to work?
> and yes, i know i could just look up the type of the column of
> interest, but i'm trying to make the function somewhat independent
> of table alterations (the whole reason for the %TYPE inclusion in
> postgresql in the first place!)
>
> thanks for any help!
>
> murat
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org


Re: function return type is a setof some column type

From
Stephan Szabo
Date:
On Sat, 4 Feb 2006, Murat Tasan wrote:

> whoa.  sorry about this post.  i already posted this about 1 week
> ago, and it's been resolved.  i have no clue why it is showing up
> again on the list.

Probably just that a copy was sitting around for moderator approval, for
example, if you weren't subscribed when you first sent it. Since there
were a few messages that seemed to just come through, that's probably it.
That happens occasionally, don't worry about it. ;)