I am trying to make a cron job that runs once a day. On invoking the shell script, it calls a Sql file. Which in turn Spools data into a file. This file is Picked by Shell Script and then mailed accordingly. Problem is when I try to spool data , it is writing elapsed time instead of writing actual result of query to the output file.
Here is the sql file I am using.
set define off
set numformat 99999999999999999999999999
set markup html on
set serveroutput on
set head on
set pages 3000
set echo off
DECLARE
total integer :=0;
total = select count(*) from t_c_table1 vt, t_c_table2 ti WHERE vt.f_item_id = ti.f_item_id (+) AND (f_update_date < sysdate - 30)order by F_INSERT_DATE desc;
IF total > 0 then
spool /home/output.csv
select f_name, count (*) from t_c_table1 where F_INSERT_DATE < sysdate-100 group by f_item_provider_id;
spool off
END IF
I get output like Elapsed: 00:00:00.506 in the spooled csv file.
Where am i going wrong? Please Help. Thanks in Advance..