Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group