The following bug has been logged online: Bug reference: 6213 Logged by: Ramanujam Email address: innomot...@gmail.com PostgreSQL version: 9.0 Operating system: linux x86_64 Description: COPY does not work as expected in a plpgsql function Details:
A function like this: CREATE OR REPLACE FUNCTION test(parm character varying(3)) RETURNS SETOF integer AS $BODY$ BEGIN COPY (SELECT $1) TO '/tmp/test.txt' CSV; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 100; Throws an error: NUM:42P02, DETAILS:there is no parameter $1 Substrituting $1 with parm gives this error: NUM:42703, DETAILS:column "parm" does not exist -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs