Re: Automate copy - Postgres 9.2

Поиск
Список
Период
Сортировка
От Patrick B
Тема Re: Automate copy - Postgres 9.2
Дата
Msg-id CAJNY3it5ke-s5rufQR15+4tk1=8DEMtuPF5bJRyZasxnfs4JDw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Automate copy - Postgres 9.2  (rob stone <floriparob@gmail.com>)
Ответы Re: Automate copy - Postgres 9.2  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Hi guys,

I created this function:

CREATE or REPLACE FUNCTION function(account_id integer)
RETURNS void AS $$
begin
execute 'COPY
(
SELECT * FROM backup_table WHERE account_id = ' || account_id || 'AND status = 1
)
TO ''/var/lib/pgsql/'||account_id||'.sql''';
end
$$ language 'plpgsql';


The function works fine.. but is not what I need, actually.
The function above works by calling it specifying the account_id. For example:

You want to copy ( backup ) for the account_id number 63742:

select function(63742);

What I need is:

When calling the function, I have to specify the limit of account_ids to be copied. For example:
To perform the commands in the function to 40 different account_ids:

select function (40);

 
How can I do that? I can't...

Cheers
Patrick

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

Предыдущее
От: Alvaro Aguayo Garcia-Rada
Дата:
Сообщение: Re: BDR
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Automate copy - Postgres 9.2