Re: Function with COPY command?

Поиск
Список
Период
Сортировка
От Shoaib Mir
Тема Re: Function with COPY command?
Дата
Msg-id bf54be870706141306g3b739f47l374f7e8d53f56da2@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Function with COPY command?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Something like this will help:

CREATE OR REPLACE FUNCTION import_text_file(char(255)) RETURNS void AS $$
DECLARE
    filename  ALIAS FOR $1;
    fin varchar;
BEGIN
    fin := 'COPY table from ' || filename;   
    execute fin;
END;
$$ LANGUAGE plpgsql;

--
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)


On 6/14/07, Tom Lane <tgl@sss.pgh.pa.us > wrote:
Warren <warren@clarksnutrition.com > writes:
> Is there any way to make this function work?

> CREATE OR REPLACE FUNCTION import_text_file(char(255)) RETURNS void AS $$
> DECLARE
>      filename ALIAS FOR $1;
> BEGIN
>      COPY table FROM filename;
> END;
> $$ LANGUAGE plpgsql;

Use EXECUTE.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: COPY Command and a non superuser user?
Следующее
От: "Mason Hale"
Дата:
Сообщение: Hash Aggregate plan picked for very large table == out of memory