Re: How to write a psql command inside a function? - Mailing list pgsql-general

From Siva Palanisamy
Subject Re: How to write a psql command inside a function?
Date
Msg-id 90F0F47595235141A4380FCF01B0185B20BC49F09D@CHN-HCLT-EVS07.HCLT.CORP.HCL.IN
Whole thread Raw
In response to Re: How to write a psql command inside a function?  (Chris Travers <chris.travers@gmail.com>)
List pgsql-general
Hi Chris,

I don't have super-user. So I knew I can go with only \COPY command. I want to export the data from a table to a .CSV
file.It worked fine when this command is used as a stand-alone. Now, I want to embed this line inside a function. Is
thereany alternative way for my requirement? Please guide me. John has proposed to see COPY to STDOUT which I am not
awareof, and started looking into it. However, the operations I said above have suppose to be done only on the database
side!

Thanks and Regards,
Siva.


-----Original Message-----
From: Chris Travers [mailto:chris.travers@gmail.com]
Sent: Wednesday, August 17, 2011 11:12 AM
To: Siva Palanisamy
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] How to write a psql command inside a function?

On Tue, Aug 16, 2011 at 10:33 PM, Siva Palanisamy <siva_p@hcl.com> wrote:
> Hi All,
>
>
>
> I want to have a psql command '\COPY' inside a function. By default, this
> command works as such. But, not inside a function. Please guide me.
>
I don't think that works  I think you have to use SQL commands since,
well, the function is running in the db, not in your client.

Look up the SQL COPY command instead.

Best Wishes,
Chris Travers

::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

pgsql-general by date:

Previous
From: Sim Zacks
Date:
Subject: Re: Using Postgresql as application server
Next
From: alexondi
Date:
Subject: Re: Run server recovery