Returning composite types from a plpgsql function

Поиск
Список
Период
Сортировка
От Joseph Barillari
Тема Returning composite types from a plpgsql function
Дата
Msg-id m3offwaprb.fsf@washer.barillari.org
обсуждение исходный текст
Ответы Re: Returning composite types from a plpgsql function
Список pgsql-sql
Hi,

I've read in the mailing list archives that plpgsql does not support
assignment to array variables, so it is impossible to use them to
return data from a plpgsql function.

I'm curious as to how one might return more than one base type from
such a function, short of creating a temporary table and inserting the
value into that. For example:

CREATE TABLE tmp (a INTEGER, b INTEGER); --define the type

CREATE OR REPLACE FUNCTION frob()
RETURNS tmp AS '
DECLARE
ret tmp%ROWTYPE;
BEGIN
ret.a := 1;
ret.b := 2;
return ret;
END;'
LANGUAGE 'plpgsql';

Unfortunately, when I execute this, I get:

cal=> select frob();  frob
-----------172795360
(1 row)

Is there some sort of type coercion I have to do to get this to work?

Thanks,

Joe

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

Предыдущее
От: Joseph Barillari
Дата:
Сообщение: Odd behavior with timestamp/interval arithmetic
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Returning composite types from a plpgsql function