Re: BUG #6213: COPY does not work as expected in a plpgsql function

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Ramanujam <innomotive(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6213: COPY does not work as expected in a plpgsql function
Date: 2011-09-26 00:57:28
Message-ID: CA+TgmoY7=pAGxqWLJq9HnTXTFyKJrP+RVJysaFaFWsBzv=AYAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, Sep 18, 2011 at 10:55 PM, Ramanujam <innomotive(at)gmail(dot)com> wrote:
> The following bug has been logged online:
>
> Bug reference:      6213
> Logged by:          Ramanujam
> Email address:      innomotive(at)gmail(dot)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

Does it work if you use EXECUTE?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2011-09-26 01:16:42 BUG #6222: Segmentation fault on unlogged table
Previous Message Tom Lane 2011-09-25 22:54:39 Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**