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

From: "Ramanujam" <innomotive(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6213: COPY does not work as expected in a plpgsql function
Date: 2011-09-19 02:55:10
Message-ID: 201109190255.p8J2tAX0011023@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message yulin liu 2011-09-19 06:47:28 BUG #6214: can't change Column COLLATE
Previous Message Robert Haas 2011-09-18 21:10:05 Re: BUG #6205: ERROR: temporary tables cannot specify a schema name