Обсуждение: How to write a psql command inside a function?

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

How to write a psql command inside a function?

От
Siva Palanisamy
Дата:

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.

 

Thanks and Regards,

Siva.

 



::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.

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

Re: How to write a psql command inside a function?

От
Chris Travers
Дата:
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

Re: How to write a psql command inside a function?

От
Siva Palanisamy
Дата:
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.

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