我正在尝试创建一个 SQL 报告。这是选择语句:
select
-- ticket id
'<tr align=left valign=top><td width=95>'||maspid||'</td>'||
-- priority
case when instr(masfld017, '<|lang' ) = 0 then
'<td width=90>'||masfld017
else
'<td width=90>'||substr( masfld017, 1 , instrb(masfld017, '<|lang') - 1)
end||'</td>'||
-- customer
'<td width=150>'||masfld007||'</td>'||
-- status
'<td width=100>'||decode(masfld104, '0', 'Collected',
'1', 'Postponed',
'2', 'Accepted',
'3', 'in Progress',
'5', 'Work Around',
'7', 'Solved',
'8', 'Closed')||'</td>'||
-- subject
'<td width=400>'||masfld001||'</td>'||
-- full name
'<td width=100>' || replace(replace(masfld037, '<||>'), '</||>')||'</td>'||
-- creation date
'<td width=150>'||to_char(to_date(masfld022, 'YYYYMMDDHH24MI'), 'DD.MM.YYYY HH24:MM')||'</td>'||
-- target date
'<td width=150>'||to_char(to_date(masfld023, 'YYYYMMDDHH24MI'), 'DD.MM.YYYY HH24:MM')||'</td>'||
-- ticket type
'<td width=180>'||decode(masfld040, '9', 'HUS',
'8', 'Project',
'7', 'Enhancement',
'6', 'Complaint',
'5', 'Change Request',
'4', 'Bug (Do not use)',
'3', 'Support',
'2', 'Service Request',
'1', 'Incident (Problem)',
null, 'N/A')||'</td></tr>'
from
k2h.tmaster01 tm inner join k2h.tprofile tp on replace(replace(tm.masfld035, '<||>'), '</||>') = tp.propid
where
masfld024 is null and
masfld082 = '®ION'
order by case masfld017
when 'Emergency' then 1
when 'Critical' then 2
when 'High' then 3
when 'Major Problem' then 4
when 'Major defect' then 5
when 'Semi-major defect' then 6
when 'Medium' then 7
when 'Minor Problem' then 8
when 'Low' then 9
end;
如果我直接用 sqldeveloper 运行它,我会得到一个结果列表。如果报告由 crontab 启动,则会失败并显示以下错误消息:
SP2-0734: unknown command beginning "case when ..." - rest of line ignored. SP2-0734: unknown command beginning "'
似乎案件command
不被认可,但为什么呢?