I have a requirement where I need to run a .sql file from a .bat file. The output of the .sql file should be redirected to a .txt file. I'm able to do this however the sql file is printing column names underlined by '_' and at the end of the file it is printing '3 rows selected'. I don't want the column names and '3 rows selected' to appear in the output file. Can you please point what am I doing wrong here? Below are the details of my code. Note that my sql has to run in oracle db using sqlplus.
sql_file.sql
SET HEADING OFF FEEDBACK OFF ECHO OFF PAGESIZE 0
SET UNDERLINE off
select 'This '|| emp_name || ' belongs to ' || dept_name || ' department' as emp_data from emplyoee;
exit
batch_file.bat
@echo off
sqlplus -s -l scott/tiger@myoracledb @"C:\Data Files\sql_file.sql" >> "C:\Data Files\output_file.txt"
I want the output_file.txt to look like
This Charles employee belongs to Finance department
This Chris employee belongs to Sales department
This John employee belongs to Engineering department
However my code is producing the output as
emp_data
--------------------------------------------------
This Charles employee belongs to Finance department
This Chris employee belongs to Sales department
This John employee belongs to Engineering department
3 rows selected