Re: variable in COPY <table> TO variable

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Rob Shepherd *EXTERN*" <rgshepherd(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: variable in COPY <table> TO variable
Date: 2007-10-17 07:14:07
Message-ID: D960CB61B694CF459DCFB4B0128514C25DD06D@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rob Shepherd wrote:
> I'm following the synatx
>
> COPY <tablename> TO 'filename'
>
> .....but i'm trying to use a variable as the filename.
>
[...]
>
> returns the error....
>
> ERROR: syntax error at or near "$1" at character 21
> QUERY: COPY tt_archive TO $1
> CONTEXT: SQL statement in PL/PgSQL function "archive" near line 16

A case for dynamic SQL!
http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQ
L-STATEMENTS-EXECUTING-DYN

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marek Lewczuk 2007-10-17 07:14:19 Re: 8.3 beta problems
Previous Message Tom Lane 2007-10-17 06:40:14 Re: 8.2.3: Server crashes on Windows using Eclipse/Junit