Hi..
I have to write a batch file which will call a sql file by passing one parameter. The sql file has to select two columns from a table and return them to the batch file and the batch file should display it on the screen.
Can I get some inputs or help in writing this.
Many thanks
I like funnelling all of my output to a file, so I can check the file for errors as well as extracting the content I want. So I might have something like this (I'm using ksh in this instance)
tmpfile=/tmp/myjob.$$
print "
connect / as sysdba
set pages 0
set lines 200
set feedback off
set trimspool on
set serverout on
select '@COUNT '||count(*) x from all_tables
exit" | sqlplus -s /nolog 1>$tmpfile 2>&1
errs=`egrep '(SP2|ORA-)' $tmpfile`
if [ "$errs" ] ; then
cat $tmpfile | mailx -s "ERROR: SOMETHING FAILED $bkptime" ops@business.com
exit
fi
obj_count=`egrep '^@COUNT' $tmpfile | awk '{print $2}'`