COPY TO File: Using dynamic file name in stored procedure

Поиск
Список
Период
Сортировка
От Carlos Oliva
Тема COPY TO File: Using dynamic file name in stored procedure
Дата
Msg-id C34A4F8A078F5E4285EB8B10FF0DAF3101F69FC7@pbsi-sbsxch.PosBus.local
обсуждение исходный текст
Ответы Re: COPY TO File: Using dynamic file name in stored procedure  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Список pgsql-general

Hi,

What would it be the correct format for using a variable in a stored procedure that uses COPY TO?

 

I have the current stored procedure:

CREATE FUNCTION Table_To_File(text) RETURNS void AS $delimeter$

   COPY (SELECT * FROM table_to_xml('table', true, false, '')) TO '$1' WITH CSV QUOTE ' ';

$delimeter$

LANGUAGE SQL;

 

When I run the stored procedure: psql –d <db name> -c “select Table_To_File(‘some_absolute_file_name’)”;  I get the error that I must use absolute file names.

 

When I replace TO ‘$1’ with TO ‘/tmp/toto.xml’, the stored procedure runs fine and creates the local file.

 

I have tried several different ways to escape the $1 variable to no avail.  At best, I get the same error.

 

 




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

Предыдущее
От: Jack Christensen
Дата:
Сообщение: Re: Optimise PostgreSQL for fast testing
Следующее
От: John R Pierce
Дата:
Сообщение: Re: How to enable thread safety on postgresql 8.3.6