I've created a pgsql script and saved it into a file. This script is creating idexes. I need to run this script on several database. I use PostgreSQL 9.3 on Windows 8.
I've created a batch file to call psql on every database and run the script. This works fine except in the shell I have a lot more messages than in my output file. Meaning when something goes wrong (i.e. a failed unique index) I see it in the shell but not in my output file. And because the shell is filled with messages I'm missing errors and warnings.
In my pgsql script I use
SET client_min_messages to 'LOG';
raise log 'Dropped index %', l_index_name;
My Windows batch file is
@echo off
set _psql="D:\Program Files\PostgreSQL\9.3\bin\psql.exe"
set _server=localhost
set _port=5432
set _file=create_indexes.sql
set _log=create_indexes.log
FOR %%G IN (db1 db2 db3) DO (
%_psql% -d %%G -h %_server% -p %_port% -U postgres -w postgres <%_file% >>%_log%
echo Done with %%G
)
pause
I've been reading post about using >output.log, like
create_indexes.bat >output.log
The file is created but has only a few irrelevant messages.
Any suggestion is more than welcome.