用于监视所需SQL查询结果的工具

时间:2009-12-02 09:26:11

标签: sql oracle monitor

我正在寻找一种工具来监控定期运行的sql查询的结果,并根据查询返回任何结果的事实引发通知。 (欢迎任何其他过滤器)

我需要查看事务表中的错误,如果我的sql查询可以在后台运行,定期刷新并在有任何结果时显示通知,那就太棒了。

我需要连接到Oracle DB,我目前使用PL / SQL Developer或Oracle SQL Developer。

免费,操作系统和轻量级解决方案首选:)

更新:

最好我不想创建/修改任何数据库对象。我们也希望在我们的客户端数据库上使用它,并且并非所有人都有权修改运行Oracle应用程序的数据库。

提前谢谢

3 个答案:

答案 0 :(得分:3)

如何使用DBMS_Scheduler运行查询表的存储过程,然后在出现问题时使用UTL_Mail发送电子邮件?

答案 1 :(得分:0)

将查询放入存储过程。在那里有你的监控/通知代码。

答案 2 :(得分:0)

我使用它,它的工作非常好。

- 1.创建程序:

BEGIN 
 DBMS_SCHEDULER.CREATE_PROGRAM(
      program_name=>'user.TABLESPACE_MANAGEMENT',
      program_action=>'begin
        EXECUTE IMMEDIATE 
'CREATE TABLE IDLE_TIME_TABLE 
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING
AS 
SELECT DISTINCT 
            SID, 
            OSUSER, 
            USERNAME, 
            STATUS,
            TO_CHAR(LOGON_TIME, ''DDth  DAY  HH24:MI:SS'') LOGON_TIME,
            FLOOR(LAST_CALL_ET/3600)||'':''|| FLOOR(MOD(LAST_CALL_ET,3600)/60)||'':''||MOD(MOD(LAST_CALL_ET,3600),60) IDLE, 
            PROGRAM
FROM V$SESSION
WHERE USERNAME IS NOT NULL
AND STATUS = ''INACTIVE''
ORDER BY IDLE DESC',
      program_type=>'PLSQL_BLOCK',
      number_of_arguments=>0,
      comments=>'TABLESPACE MANAGEMENT CREATES A TABLE CALLED TABLESPACE_MANAGEMNT ON DAILY BASIS',
      enabled=>TRUE);
END;

- 2.创建计划程序:

BEGIN
   sys.dbms_scheduler.create_schedule( 
      repeat_interval =>   
         'FREQ=DAILY; BYDAY=MON,TUE,WED,THU,FRI; BYHOUR=22; BYMINUTE=0; BYSECOND=0;',
      start_date => 
         to_timestamp_tz('2011-07-26 US/Eastern', 'YYYY-MM-DD TZR'),
      comments => 
         'Schedule for what ever u want',
      schedule_name => '"user"."TABLESPACE_MANAGEMENT_SCHEDULE"');
END;

- 3。最后将两者链接在一起以创建一个JOB:

BEGIN
   sys.dbms_scheduler.create_job( 
      job_name => '"user"."SPACE"',
      program_name => 'user.TABLESPACE_MANAGEMENT',
      schedule_name => 'user.TABLESPACE_MANAGEMENT_SCHEDULE',
      job_class => 'DEFAULT_JOB_CLASS',
      comments => 'TABLESPCE_MANAGEMENT',
      auto_drop => FALSE,
      enabled => TRUE);
END;

现在您可以使用类似utl_mail.send

的内容
begin
 UTL_MAIL.SEND_ATTACH_VARCHAR2
(
        sender => 'username@whatever.co.uk'
       ,recipients => 'username@whatever.co.uk,username@whatever.co.uk,username@whatever.co.uk,username@whatever.co.uk'
       ,cc => NULL
       ,bcc =>  NULL
       ,subject => 'send_attach_varchar2'
       ,message => 'here is a test of send_attach_varchar2'
       ,mime_type => 'text/plain; charset=us-ascii'
       ,priority => 3
       ,attachment => '<html>
                                        <head>
                                          <title>Test HTML message</title>
                                        </head>
                                        <body>
                                          <p>This is a <b>HTML</b> <i>version</i> of the test message.</p>
                                          <p><img src="http://whatever/images/site_logo.gif" alt="Site Logo" />
                                        </body>
                                      </html>'
       ,att_inline => TRUE
       ,att_mime_type=>'application/html'
       ,att_filename => 'cartesien.html'
   );