bulk insertions in PL/pgsql functions - Mailing list pgsql-general

From Richard Emberson
Subject bulk insertions in PL/pgsql functions
Date
Msg-id 3C7ECBB9.32D8A7E1@phc.net
Whole thread Raw
List 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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: killed select?
Next
From: Samik Raychauhduri
Date:
Subject: Re: SQL statement : list table details