Re: Automate copy - Postgres 9.2

Поиск
Список
Период
Сортировка
Искать
От
John R Pierce
Тема
Re: Automate copy - Postgres 9.2
Дата
Msg-id
4c11c823-bea0-2088-2967-a7fff8914fd1@hogranch.com
Ответ на
Список
Дерево обсуждения
Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 Adrian Klaver <adrian.klaver@aklaver.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 John R Pierce <pierce@hogranch.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 John R Pierce <pierce@hogranch.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 Rob Sargent <robjsargent@gmail.com>
Re: Automate copy - Postgres 9.2 John R Pierce <pierce@hogranch.com>
Re: Automate copy - Postgres 9.2 John R Pierce <pierce@hogranch.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 "David G. Johnston" <david.g.johnston@gmail.com>
Re: Automate copy - Postgres 9.2 rob stone <floriparob@gmail.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 Adrian Klaver <adrian.klaver@aklaver.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
Re: Automate copy - Postgres 9.2 rob stone <floriparob@gmail.com>
Re: Automate copy - Postgres 9.2 Melvin Davidson <melvin6925@gmail.com>
Re: Automate copy - Postgres 9.2 Patrick B <patrickbakerbr@gmail.com>
On 6/8/2016 4:24 PM, Patrick B wrote:

I need to do a file backup for each account_id.

Example:

COPY 
(
SELECT * FROM backup_table WHERE id = 1112 AND status = 1
) 
TO '/var/lib/pgsql/1112.sql';

COPY generates CSV and similar formats, not .sql.   only pg_dump, the command line utility, outputs .SQL

begin
      FOR crtRow in execute 'select account_id from backup_table WHERE migrated = 1 AND account_id = '|| $1

      LOOP
    COPY
        (SELECT * FROM gorfs.WBP_4868_backup_table_BLOBS WHERE migrated = 1 AND account_id = crtRow.account_id)
    TO '/var/lib/pgsql/gorfs_backup/%s.sql';
    end loop;
    return integer;
end

try...


begin
      FOR crtRow in
            select account_id from backup_table WHERE migrated = 1 AND account_id in $1
      LOOP
    COPY
        (SELECT * FROM gorfs.WBP_4868_backup_table_BLOBS WHERE migrated = 1 AND account_id = crtRow.account_id)
    TO '/var/lib/pgsql/gorfs_backup/' || crtRow.account_id || '.csv';
    end loop;
    return integer;
end


but you can't exactly return 'integer' if its a list of values, so I'm not sure what it is you want to return from this function...



-- 
john r pierce, recycling bits in santa cruz
В списке pgsql-general по дате отправления
От: Patrick B
Дата:
Сообщение: Automate copy - Postgres 9.2
От: Adrian Klaver
Дата:
FAQ