Reputation: 51
@echo off
set user_name=username
set password=
set sid=sid
@echo select distinct scid, to_char(dlog_on_timestamp,'dd-Mon-YYYY hh:mi:ss') from table where dlog_on_timestamp > sysdate-7; | sqlplus -s %user_name%/%password%@%sid% >> C:\Users\test.txt
While running this batch file, > symbol created file sysdate-7. But I need to run the DB query and the result should be stored in test.txt
Upvotes: 0
Views: 161
Reputation: 3925
Put quotes for your shell (cmd.exe
?) around the command:
@echo "select distinct scid, to_char(dlog_on_timestamp,'dd-Mon-YYYY hh:mi:ss') from table where dlog_on_timestamp > sysdate-7;" | sqlplus -s %user_name%/%password%@%sid% >> C:\Users\test.txt
Upvotes: 1