function returning a setof a column type

From: Murat Tasan <murat(dot)tasan(at)cwru(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: function returning a setof a column type
Date: 2006-01-31 15:10:28
Message-ID: ABC37423-F458-4F4A-83A5-0A63FBF723D1@cwru.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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;
ERROR: syntax error at or near "%" at character 59
LINE 1: ...ate function test_function() returns setof table.column%
TYPE as $...

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

=> CREATE FUNCTION test_function() RETURNS table.column%TYPE AS $$
SELECT 1; $$ LANGUAGE SQL;
NOTICE: type reference table.column%TYPE converted to integer
CREATE FUNCTION

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

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

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-01-31 15:48:10 Re:
Previous Message Tomka Gergely 2006-01-31 15:07:30 Re: lost archives, alpha data files