Hi! I'm using DOS on Windows XP. My database is PostgreSQL 8.2. I've been trying to code a small export process. My .bat runs a .sql that contains some basic select statements. The output is catted to a .txt file. However, every record (header, detail and trailer) in the .txt file contains a space as the first byte. I don't think the space is generated by the SQL as there is no space in the output when I cat the data to a temp table. I cannot figure out why a space is being inserted as the first byte of the .txt file. Any thoughts? The .bat code is below.
set PGDB=test_works
set PGUSER=postgres
set PGPASSWORD=test
set PGPATH=C:\Program Files\PostgreSQL\8.2\bin\
set BASEDIR=C:\TEAMS
set DATADIR=%BASEDIR%\OUTPUT\
set SCRIPTDIR=%BASEDIR%\SCRIPTS\
set LOGDIR=%BASEDIR%\LOGS\
SET dtOnly=%1
IF NOT DEFINED dtOnly call getDateTime.bat
echo %dtOnly% > tmpFile
"%PGPATH%psql.exe" %PGDB% -U %PGUSER% -f "%SCRIPTDIR%SetExpDate.sql" -q -t
"%PGPATH%psql.exe" %PGDB% -U %PGUSER% -f "%SCRIPTDIR%TEAMS_EXPORT_EV.sql" -L "%LOGDIR%TEAMS_EXPORT_EV%dtOnly%.log" -q -t -o "%DATADIR%TEAMS_EXPORT_EV%dtOnly%.txt" >> "%LOGDIR%TEAMS_EXPORT_EV%dtOnly%.err" 2>&1
del tmpFile