Обсуждение: Casting 'record' to a composite type.

Поиск
Список
Период
Сортировка

Casting 'record' to a composite type.

От
Mark Gibson
Дата:
Hello,
When using functions that return the datatype 'record', rather than
doing this:

    SELECT *
    FROM fn_returning_setof_record( ... )
    AS t (id integer, title text);

I'd like to do something like this:

    CREATE TYPE my_type AS (id integer, title text);

    SELECT *
    FROM fn_returning_setof_record( ... )
    AS t my_type;
or
    SELECT *
    FROM fn_returning_setof_record( ... )::my_type AS t;

Obviously the last two statements don't work, but you can see what I'm
getting at,
casting the 'record' datatype to a composite datatype.
I've not been able to find anything like this in the docs.
Is there currently any way of doing this? are there any plans for it?

Cheers

--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.


Re: Casting 'record' to a composite type.

От
Joe Conway
Дата:
Mark Gibson wrote:
> I'd like to do something like this:
>
>    CREATE TYPE my_type AS (id integer, title text);
>
>    SELECT *
>    FROM fn_returning_setof_record( ... )
>    AS t my_type;
> or
>    SELECT *
>    FROM fn_returning_setof_record( ... )::my_type AS t;

> I've not been able to find anything like this in the docs.
> Is there currently any way of doing this? are there any plans for it?

There is no way to do this now, and no plans that I know of, but it does
look useful. I'm not sure how painful it would be to make it happen
though...

Joe