我正在运行一个调用sqlplus脚本的win bat脚本,然后通过电子邮件发送sqlplus脚本的输出,这是我的脚本
ttitle left 'Last Successful Run for Oracle or Siebel'
break on cntry skip 1;
set pages 100;
select lpad(country,6,' ') cntry, max(timestamp) Timestamp,substr(LPAD(test_type,10,' '),0,10) Type,
CASE
WHEN ((sysdate-max(timestamp))*1440) >=60 THEN '<===== ERROR over 60 minutes since last run'
WHEN ((sysdate-max(timestamp))*1440) >=30 THEN '<===== WARNING over 30 minutes since last run'
ELSE ''
end as status
from rfgdba.perf_test_results ptr, rfgdba.perf_tests pt
where country is not null and test_id in ((select id from rfgdba.perf_tests where live='Y')) and test_type in ('ORACLE','SIEBEL')
and timestamp > sysdate-30 and ptr.test_id=pt.ID
group by country, test_type
order by country, timestamp ;
输出是表格格式,但我想在CASE部分周围添加颜色编码,即如果值> 60,则将txt backgroudn红色着色,如果值> 30 <60则txt backgroudn orange和if值是&lt; 30然后txt背景绿色,但我不能让它工作,我尝试了以下
CASE
WHEN ((sysdate-max(timestamp))*1440) >=60 THEN '<tr style="color:red'||'<===== ERROR over 60 minutes since last run'||'"></tr>'
WHEN ((sysdate-max(timestamp))*1440) >=30 THEN '<tr style="color:orange'||'<===== WARNING over 30 minutes since last run'||'"></tr>'
ELSE <tr style="color:green'||''||'"></tr>'
end as status
但它出错了
错误: ORA-01756:引用的字符串未正确终止
所以我很难过:(