How to get text for a plpgsql variable from a file. - Mailing list pgsql-general

From Erwin Brandstetter
Subject How to get text for a plpgsql variable from a file.
Date
Msg-id edb0d0ce-b9c2-462c-9477-e7cd837ac2e4@19g2000vbq.googlegroups.com
Whole thread Raw
Responses Re: How to get text for a plpgsql variable from a file.  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: How to get text for a plpgsql variable from a file.  ("Greg Sabino Mullane" <greg@turnstep.com>)
Re: How to get text for a plpgsql variable from a file.  (Erik Jones <ejones@engineyard.com>)
List 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

pgsql-general by date:

Previous
From: Michael Clark
Date:
Subject: Re: Possible causes for database corruption and solutions
Next
From: Tim Hart
Date:
Subject: make check fails on OS X 10.6.2