Re: How to give \COPY inside a function

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: How to give \COPY inside a function
Дата
Msg-id 4E4A8941.8000406@hogranch.com
обсуждение исходный текст
Ответ на How to give \COPY inside a function  (Siva Palanisamy <siva_p@hcl.com>)
Ответы Re: How to give \COPY inside a function  (Siva Palanisamy <siva_p@hcl.com>)
Список pgsql-general
On 08/16/11 8:07 AM, Siva Palanisamy wrote:
>
> I want to \COPY over COPY command as I am not running as a super/admin
> user. How to add \COPY command inside a function.
>
> The following statement inside a function throws error.
>
> \COPY xsa.export_table TO 'export.csv' DELIMITERS ',' CSV HEADER
>
> Errors are throwing at “\COPY” and no semi-colon at the end of the
> line. Please guide me.
>

\COPY is a psql metacommand, not a proper SQL command, its translated to
a SQL COPY command. you can't use \ commands in functions, so you'll
need to recode that as a COPY ... TO STDOUT ...; and recieve the stdout
stream and write it to your file (which is what the \COPY command is doing).



--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast



В списке pgsql-general по дате отправления:

Предыдущее
От: Siva Palanisamy
Дата:
Сообщение: How to give \COPY inside a function
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: [ADMIN] Using Postgresql as application server