0
@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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.