bulk insertions in PL/pgsql functions

From: Richard Emberson <emberson(at)phc(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: bulk insertions in PL/pgsql functions
Date: 2002-03-01 00:30:49
Message-ID: 3C7ECBB9.32D8A7E1@phc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rather than insert values one row at a time from a client to a backend
could one do a bulk load
using a function:

CREATE OR REPLACE FUNCTION bulk_load (
TEXT
)
RETURNS INTEGER AS '
DECLARE
-- parameters
text_p ALIAS FOR $1;
-- local variables
-- none
BEGIN
EXECUTE ''COPY some_table FROM stdin:''
|| text_p
|| ''\.''
RETURN 1;
END;
' LANGUAGE 'plpgsql';

Here the argument would have to be of the correct rormat for the copy
command.
(Assume that there is not a shared filesystem so one can not write the
data to a file
and have it then loaded via a copy from filename command be used.)

Richard

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-03-01 00:58:48 Re: SQL statement : list table details
Previous Message Tom Lane 2002-02-28 21:48:21 Re: killed select?