Обсуждение: Writing Text Files from PostgreSQL

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

Writing Text Files from PostgreSQL

От
"William Gerber"
Дата:
Hello.  I am brand new to PostgreSQL and I need someone to point me in
the right direction on how to write the results of a function to a text
file.  Is it possible to do this within the PostgreSQL PL/pgSQL
language?  I have done this before in Oracle using the UTL_FILE commands
and I was hoping that PostgreSQL had similar functionality.  I need to
provide some data formatting in the text file that I produce so I don't
think the pg_dump command would work for me (correct me if I am wrong
though).  Thanks in advance for any help that you can give.

System Specs:
PostgreSQL 8.1 on Linux

--------------------------------------------------------------
   William Gerber
   ERG
   5608 Parkcrest Drive, Suite 100
   Austin, TX 78731-4947
   ph: 512-407-1827
   fax: 512-419-0089
   e-mail: william.gerber@erg.com
--------------------------------------------------------------

Re: Writing Text Files from PostgreSQL

От
Jaime Casanova
Дата:
On 11/16/05, William Gerber <William.Gerber@erg.com> wrote:
> Hello.  I am brand new to PostgreSQL and I need someone to point me in
> the right direction on how to write the results of a function to a text
> file.  Is it possible to do this within the PostgreSQL PL/pgSQL
> language?  I have done this before in Oracle using the UTL_FILE commands
> and I was hoping that PostgreSQL had similar functionality.  I need to
> provide some data formatting in the text file that I produce so I don't
> think the pg_dump command would work for me (correct me if I am wrong
> though).  Thanks in advance for any help that you can give.
>

psql DBname -f script > file
or
psql DBname -c "sql_command;"

psql --help to see options for formatting

>
> System Specs:
> PostgreSQL 8.1 on Linux
>
> --------------------------------------------------------------
>   William Gerber
>   ERG
>   5608 Parkcrest Drive, Suite 100
>   Austin, TX 78731-4947
>   ph: 512-407-1827
>   fax: 512-419-0089
>   e-mail: william.gerber@erg.com
> --------------------------------------------------------------
>


--
Atentamente,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

Re: Writing Text Files from PostgreSQL

От
Andreas Kretschmer
Дата:
William Gerber <William.Gerber@erg.com> schrieb:

> Hello.  I am brand new to PostgreSQL and I need someone to point me in
> the right direction on how to write the results of a function to a text
> file.  Is it possible to do this within the PostgreSQL PL/pgSQL

No, this is a trusted language. But you can use untrusted languages such
as plperlu or plsh.

21:05 < akretschmer> ??plperl
21:05 < rtfm_please> For information about plperl
21:05 < rtfm_please> see http://pgfoundry.org/projects/plperlng/
21:05 < rtfm_please> or http://www.postgresql.org/docs/current/static/plperl.html


HTH, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°