Обсуждение: bulk insertions in PL/pgsql functions

Поиск
Список
Период
Сортировка

bulk insertions in PL/pgsql functions

От
Richard Emberson
Дата:
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