function returns setof column type problems

Поиск
Список
Период
Сортировка
От mmuurr[AT]gmail.com
Тема function returns setof column type problems
Дата
Msg-id 1138722491.367926.123850@g14g2000cwa.googlegroups.com
обсуждение исходный текст
Список pgsql-general
hi all,

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!


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: help with locked table(s)/transactions(s)
Следующее
От: The Doctor
Дата:
Сообщение: Help in compiling 8.1.2 from source