Skip site navigation (1) Skip section navigation (2)

Re: dynamic crosstab

From: Andy Colson <andy(at)squeakycode(dot)net>
To: Pierre Chevalier <pierre(dot)chevalier1967(at)free(dot)fr>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: dynamic crosstab
Date: 2010-01-28 15:11:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On 1/27/2010 3:49 AM, Pierre Chevalier wrote:
> Pavel Stehule claviota:
>>> ...
>>> But what I would like to do is to redirect the output of the function
>>> (that
>>> is, the 'result' cursor) to a view, which will be used in other
>>> places. I
>>> thought something like FETCH INTO would do the trick, but it doesn't.
>>> Also, I need, at some point, to export the output to some CSV file. I
>>> usually do a quick bash script as follows:
>>> echo "COPY (SELECT * FROM dh_litho ORDER BY id, depto) TO stdout WITH
>>> CSV
>>> HEADER;" | psql bdexplo > somefile.csv
>>> ...
>> hmm cannot work :(. You cannot forward FETCH ALL statement on
>> server side - without programming in C
> Ach! Too bad... Oh but... I used to program in C, long time ago, on
> HP-UX...

How do you feel about a little perl?  It would be pretty simple, and 
could generate a csv based on any resultset (any number of columns). 
I'd be happy to post a little get you started code if you wanted.


In response to


pgsql-general by date

Next:From: Tom LaneDate: 2010-01-28 15:51:11
Subject: Re: Function nesting issue
Previous:From: 张海峰Date: 2010-01-28 13:26:26
Subject: Re: Function nesting issue

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group