I'm using the following code inside a Windows batch (*.bat) file to run several SQL queries:
set PSTR=QUERY1,QUERY2
for %%a in (%PSTR%) do (
set START=%date%:%time%
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -f "D:\SQL\%%a.sql" -h localhost -p 5432 -U postgres db_tom
set END=%date%:%time%
echo %%a DEB %DEB% FIN %FIN% >> "D:\LOGS\log.txt"
The echo writes the following string inside the log.txt
file:
QUERY1 START END
QUERY2 START END
The variables set inside the loop are ignored. Is there another way to write this batch in order to get start and end datetime written down?