Oracle Job brocken运行后

时间:2015-11-30 10:19:22

标签: oracle plsql job-scheduling

我的预定工作有问题。这项工作安排在每天早上8点开始。如果现在我安排工作,明天它工作,运行选择并发送邮件,但然后打破。

我声明,我没有DBA许可,因此如果工作有错误,我看不到。

你有没有建议?

抱歉我的英语,非常基础,我希望你明白。

工作很简单,这就是代码:

declare 

 v_mail mail_wrapper.mail_type;
 --
 v_lines DBMSOUTPUT_LINESARRAY;
 v_num_lines NUMBER;
--
v_subject VARCHAR2(1000):= NULL;

CURSOR c_log_lines IS
SELECT *
FROM
  ( SELECT job, table_name, nr_rows, dt_upd, note FROM a_log
UNION
SELECT 'ROW_SEP' job,
  NULL table_name,
  NULL nr_rows,
  TRUNC(sysdate) + 4/24 dt_upd,
  NULL note
FROM dual
UNION
SELECT 'P_RELEASE_MANAGEMENT_ETL_TO_DB2' "JOB",
  trim(regexp_replace(note, '(INIZIO |DELETE AIC_PPM_PROJECT_| OK|FINE |DELETE |PRIMA |INSERT AIC_PPM_|AIC_PPM_|SECONDA |CHECK NUMEROSITA| ERROR|_)', ' ')) table_name,
  NULL,
  dt_upd,
  Note
FROM a_schema.a_log@other_schema
WHERE TRUNC(dt_upd) = TRUNC(SYSDATE)
  )
ORDER BY dt_upd ASC;

v_dest_1  varchar2(100):= 'aaa.ccc@sdqwe.eu';
--
BEGIN
v_subject := 'LOG RELEASE MANAGEMENT' || TO_CHAR(sysdate, 'DD-MON-YYYY');

mail_wrapper.v_from_field := 'usepdwb@mailasp.internal';
v_mail                    := mail_wrapper.create_mail_message;
MAIL_WRAPPER.ADD_SUBJECT  ( V_MAIL, V_SUBJECT  );
Mail_Wrapper.Add_To_Field ( v_mail, v_dest_1 );

mail_wrapper.add_body( v_mail, ' <TABLE border=1 cellSpacing=0 cellPadding=1 style="font-size:12px" width="90%" >');
--mail_wrapper.add_body( v_mail, '<tr bgColor=#eeeeff >' ||'<td><font size=1>Job_Name</font></td>' ||'<td><font size=1>Table_Name</font></td>' ||'<td><font size=1>Nr_Rows</font></td>' ||'<td><font size=1> Dt Update </font></td>' ||'<td><font size=1>Note</font></td>' ||'</tr>' );
mail_wrapper.add_body( v_mail, 
'<tr bgColor=#eeeeff >
  <th>Job_Name</th>
  <th>Table_Name</th>
  <th>Dt Update</th>
  <th>Note</th>
</tr>' );

FOR i IN c_log_lines
LOOP
IF i.JOB = 'ROW_SEP' THEN
  mail_wrapper.add_body( v_mail, '<tr >' ||'<td colspan=''4'' height=''20'' style=''background-color:yellow''></td>' ||'</tr>' );
ELSE
  IF i.note LIKE '%ERROR%' THEN
    mail_wrapper.add_body( v_mail, '<tr style=''background-color:red''>' ||'<td ><font size=1>  '||i.JOB||'</font></td>' ||'<td><font size=1> '||NVL(i.table_name,'_')||'</font></td>' ||'<td><font size=1> '||TO_CHAR(i.dt_upd,'dd-mon-yy hh24:mi')||'</font></td>' ||'<td><font size=1>  '||i.note||'</font></td>' ||'</tr>' );
  ELSE
    mail_wrapper.add_body( v_mail, '<tr >' ||'<td ><font size=1>  '||i.JOB||'</font></td>' ||'<td><font size=1> '||NVL(i.table_name,'_')||'</font></td>' ||'<td><font size=1> '||TO_CHAR(i.dt_upd,'dd-mon-yy hh24:mi')||'</font></td>' ||'<td><font size=1>  '||i.note||'</font></td>' ||'</tr>' );
  END IF;
END IF;
END LOOP;

mail_wrapper.add_body( v_mail, ' </table >');
Mail_Wrapper.Add_Body( V_Mail, ' </html >');
--
--
mail_wrapper.send_mail( v_mail );
EXCEPTION
 WHEN OTHERS THEN
  insert into A_LOG_RELEASE_MANAGEMENT values ('P_SEND_MAIL_LOG_REL_MNGT', null, null, sysdate, 'ERR');
END;

0 个答案:

没有答案