Re: Usage of function retruning record in query - Mailing list pgsql-sql

From Pavel Stehule
Subject Re: Usage of function retruning record in query
Date
Msg-id CAFj8pRAACK5zkYH1ePRF33gpZyJWNuzyiJfT_s9i-4zJWBBkxw@mail.gmail.com
Whole thread Raw
In response to Re: Usage of function retruning record in query  (gmb <gmbouwer@gmail.com>)
Responses Re: Usage of function retruning record in query  (gmb <gmbouwer@gmail.com>)
List pgsql-sql
2011/7/5 gmb <gmbouwer@gmail.com>:
>
> gmb wrote:
>>
>>
>> Thanks for the feedback, Harald.
>>
>> How about specifying different aliases to the resulting values?
>> This will be handy when I use the same function multiple times in the same
>> query.
>> (the function will take another input parameters used in the calculations)
>>
>> E.g.:
>> SELECT itemid, (calcvalues(itemid, '2011-06-06')).*, (calcvalues(itemid,
>> '2011-06-07')).* FROM itemlist;
>>
>>  itemid | calcval1 | calcval2 | calcval1 | calcval2
>> --------+----------+----------+----------+----------
>>       4 | 0.67     | 10.00    | 0.64     | 65.23
>>       5 | 1.55     | 45.00    | 1.23     | 23.25
>>       6 | 3.60     | 69.00    | 2.98     | 62.66
>> How will I manage unique column names for this output?
>>
> Hmm.. no takers? I guess not possible then?
> Thanks anyway
>

hello

try to wrap your query to subselect,

npcps_201=# select 1,2,2,3;?column? │ ?column? │ ?column? │ ?column?
──────────┼──────────┼──────────┼──────────       1 │        2 │        2 │        3
(1 row)

Time: 0.171 ms
npcps_201=# select * from (select 1,2,2,3) x  (a,b,c,d);a │ b │ c │ d
───┼───┼───┼───1 │ 2 │ 2 │ 3
(1 row)

Time: 0.202 ms

Regards

Pavel Stehule

> --
> View this message in context:
http://postgresql.1045698.n5.nabble.com/Usage-of-function-retruning-record-in-query-tp4549140p4552513.html
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


pgsql-sql by date:

Previous
From: gmb
Date:
Subject: Re: Usage of function retruning record in query
Next
From: gmb
Date:
Subject: Re: Usage of function retruning record in query