the problem is the query runs well in toad but doesnt work in unix script.
anyone could help?
query as follows:
select sum(case when error_text like 'SystemError:Operation Time Out (Server Side)%' then 1 else 0 END) as count
from a
where trunc(start_dtg)=trunc(sysdate)-1;
in Unix script:
declare
cursor cs is
select sum(case when error_text like 'SystemError:Operation Time Out (Server Side)%' then 1 else 0 END) as count
from a
where trunc(start_dtg)=trunc(sysdate)-1;
blah..blah..blah
but it always said,
encountered the symbol "CASE" when expecting blah blah
var=`sqlplus <user/pwd> << _EOF_
select sum(case when error_text like 'SystemError:Operation Time Out (Server Side)%' then 1 else 0 END) as count
from a
where trunc(start_dtg)=trunc(sysdate)-1;
_EOF_`
I think the problem is when unix script called sql script it doesnt recognize the "CASE" in a right way as toad can do. but dont know how to fix it.
really need help.
The result comes back from query should be as following, how can I save it as .csv file?
TRAN_DATE,EVENT_CODE,EVENT_DESC,TIME_OUT_COUNT,COUNT(*)
24/08/2005 CREATECRD Initiate Credit Check 1 241
24/08/2005 CUSTSRCH Search for Customer 4 3157