Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Harry Tuttle Newsgroups: comp.databases.postgresql Subject: Re: Returning a table in SQL Date: Tue, 26 Aug 2014 21:10:16 +0200 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net QOBcWyRgSOdvhiEnx8YdwQrPUB/OAKG9ehs5jFMkbzLTHhC9A= Cancel-Lock: sha1:/sibk/woDIS4JLGAMOe3L8ta2uA= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 In-Reply-To: Xref: csiph.com comp.databases.postgresql:588 AP wrote on 26.08.2014 19:39: > Dear USENET, > > If I have a function that returns a table , such as > > create function some_report(in param1 text) returns table(rec1 integer, rec2 text) as > $body$ > select blablabla from table1; > $body$ language 'sql' > > with report as (select some_report('Customer','2014-08-01','2014-08-08') ) > select * from report > > still returns me a table with one column into which all record fields are packed. > > How do I access rec1 and rec2 individually in such a case ? > > Thank you all in advance ! > You need to use the function like a table if it returns a table: with report as ( select * fromsome_report('Customer','2014-08-01','2014-08-08') ) select * from report