Function with COPY command?

From: Warren <warren(at)clarksnutrition(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Function with COPY command?
Date: 2007-06-14 19:13:45
Message-ID: 46719369.7050301@clarksnutrition.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

The version below works fine, but I need something like the above version.

CREATE OR REPLACE FUNCTION import_text_file(char(255)) RETURNS void AS $$
DECLARE
filename ALIAS FOR $1;
BEGIN
COPY table FROM 'C:\\somefile.txt';
END;
$$ LANGUAGE plpgsql;

--
Thanks,

Warren

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Warren 2007-06-14 19:15:23 COPY Command and a non superuser user?
Previous Message Alvaro Herrera 2007-06-14 18:43:56 Re: explain analyze on a function