Re: Untyped result (setof / rowset) from Functions ?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Untyped result (setof / rowset) from Functions ?
Дата
Msg-id 4343910A.9030304@archonet.com
обсуждение исходный текст
Ответ на Untyped result (setof / rowset) from Functions ?  ("Modern Mexican" <felipe@modernmexican.com>)
Ответы Re: Untyped result (setof / rowset) from Functions ?  ("Modern Mexican" <felipe@modernmexican.com>)
Список pgsql-general
Modern Mexican wrote:
> Is there a technical reason why an untyped result (setof / rowset) from a
> function (sql or plpgsql) is not implemented ?
>
> Something Simple:
>
> CREATE FUNCTION foo(x int) RETURNS SETOF records AS
> 'SELECT t1.*, t2.* FROM t1 INNER JOIN t2 ON t1.a=t2a
> WHERE WHERE t1.id=$1'
> LANGUAGE SQL
>
> So I will not have to create a TYPE every time I return a SETOF JOINED
> tables or a sub-set of the columns of a table.

You can do this, but you have to specify what the type is when you call
it. There needs to be *some* type defined somewhere.

See the manuals - section 7.2.1.4 which gives the following example of
specifying what results you expect from a dblink() call.

SELECT *
     FROM dblink('dbname=mydb', 'select proname, prosrc from pg_proc')
       AS t1(proname name, prosrc text)
     WHERE proname LIKE 'bytea%';

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: query execution
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: transaction toggling