How to get text for a plpgsql variable from a file.

From: Erwin Brandstetter <brsaweda(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to get text for a plpgsql variable from a file.
Date: 2009-12-16 19:19:01
Message-ID: edb0d0ce-b9c2-462c-9477-e7cd837ac2e4@19g2000vbq.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I need a long text form from a file in my plpgsql variable.
Can anyone think of a more straightforward way to read the file than
the following:

CREATE FUNCTION test() RETURNS void AS
$BODY$
DECLARE
mytxt text;
BEGIN

CREATE TEMP TABLE x (x text);
COPY x from '/path/to/myfile.txt';
mytxt := (SELECT x from x);

...

END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

Regards
Erwin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua Tolley 2009-12-16 20:44:57 Re: replication dbs
Previous Message Michael Clark 2009-12-16 19:08:32 Re: Possible causes for database corruption and solutions