How use input parameter as path to COPY in function?

From: Bill Todd <pg(at)dbginc(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How use input parameter as path to COPY in function?
Date: 2009-11-26 03:05:02
Message-ID: 4B0DF05E.9000909@dbginc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am missing something basic. How can I use an input parameter as the
destination path in a COPY statement in a function. The following fails
with a syntax error at or near the parameter.

CREATE OR REPLACE FUNCTION dvd.export_tables(IN export_path text)
RETURNS void
AS
$$
BEGIN
copy dvd.genre to export_path
with
delimiter as E'\t'
null as '';
END;
$$
LANGUAGE 'plpgsql' VOLATILE

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-11-26 04:03:05 Re: How use input parameter as path to COPY in function?
Previous Message Craig Ringer 2009-11-26 02:38:56 Re: limiting resources to users