Re: BUG #6213: COPY does not work as expected in a plpgsql function - Mailing list pgsql-bugs

From Robert Haas
Subject Re: BUG #6213: COPY does not work as expected in a plpgsql function
Date
Msg-id CA+TgmoY7=pAGxqWLJq9HnTXTFyKJrP+RVJysaFaFWsBzv=AYAQ@mail.gmail.com
Whole thread Raw
In response to BUG #6213: COPY does not work as expected in a plpgsql function  ("Ramanujam" <innomotive@gmail.com>)
Responses Re: BUG #6213: COPY does not work as expected in a plpgsql function
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**
Next
From: "Fujii Masao"
Date:
Subject: BUG #6222: Segmentation fault on unlogged table