From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | 'PostgreSQL' <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: COPY with a variable path |
Date: | 2008-11-27 23:25:15 |
Message-ID: | 492F2C5B.4010608@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 27/11/2008 23:09, Bill Todd wrote:
> Raymond O'Donnell wrote:
>> You could write a pl/pgsql function which constructs the query as a
>> string and then runs it with EXECUTE.
>>
> According to the PostgreSQL help file EXECUTE is used to execute a
> prepared statement. I tried that but when I call PREPARE with COPY as
> the statement I get an error. Are you saying that I can also use EXECUTE as
Sorry, Bill, I wasn't clear enough - I was suggesting writing a pl/pgsql
function something like this (not tested):
create function do_copy(path text) returns void
as
$$
begin
execute 'copy your_table from ' || filepath;
return;
end;
$$
language plpgsql;
EXECUTE in pl/pgsql is different from the version you refer to
above....here it is in the docs:
http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
Ray.
------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Qiang | 2008-11-28 01:42:47 | please cansel my subscription |
Previous Message | Bill Todd | 2008-11-27 23:23:31 | Re: COPY with a variable path |