On Sun, Sep 18, 2011 at 10:55 PM, Ramanujam <innomotive@gmail.com> wrote:
> The following bug has been logged online:
>
> Bug reference: =A0 =A0 =A06213
> Logged by: =A0 =A0 =A0 =A0 =A0Ramanujam
> Email address: =A0 =A0 =A0innomotive@gmail.com
> PostgreSQL version: 9.0
> Operating system: =A0 linux x86_64
> Description: =A0 =A0 =A0 =A0COPY does not work as expected in a plpgsql f=
unction
> Details:
>
> A function like this:
>
> CREATE OR REPLACE FUNCTION test(parm character varying(3)) RETURNS SETOF
> integer AS
> $BODY$
>
> BEGIN
> =A0 =A0COPY (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
Does it work if you use EXECUTE?
--=20
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company