Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 22nd, 2005, 08:53 AM
Mark Gibson
Guest
 
Posts: n/a
Default Casting 'record' to a composite type.

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.


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org




  #2  
Old November 22nd, 2005, 08:53 AM
Joe Conway
Guest
 
Posts: n/a
Default Re: Casting 'record' to a composite type.

Mark Gibson wrote:[color=blue]
> 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;[/color]
[color=blue]
> 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?[/color]

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



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.