- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2012-3-14 19:11:12
ODM Finding:- /*************************************************************
- * Special Scheduler Administrative Procedures
- *************************************************************
- */
- -- There are several scheduler attributes that control the behavior of the
- -- scheduler. These have defaults but a DBA may wish to change the default
- -- settings or view the current settings. These two functions are provided for
- -- this purpose.
- -- Even though the scheduler attributes have different types (e.g. strings,
- -- numbers) all the values are passed as string literals. The set
- -- procedure requires the MANAGE SCHEDULER privilege.
- -- This takes effect immediately, but the resulting changes may not be seen
- -- immediately.
- -- Attributes which may be set are:
- -- 'MAX_SLAVE_PROCESSES'(pls_integer), 'DEFAULT_LOG_PURGE_POLICY'(varchar2),
- -- 'LOG_HISTORY' (pls_integer)
- -- Set the value of a scheduler attribute. This takes effect immediately,
- -- but the resulting changes may not be seen immediately.
- PROCEDURE set_scheduler_attribute(
- attribute IN VARCHAR2,
- value IN VARCHAR2);
复制代码 Let's Test This procedure:
SQL> exec dbms_scheduler.set_scheduler_attribute('SCHEDULER_DISABLED','TRUE');
PL/SQL procedure successfully completed.
SQL> select * from DBA_SCHEDULER_GLOBAL_ATTRIBUTE ;
ATTRIBUTE_NAME VALUE
---------------------------------------- ----------------------------------------
MAX_JOB_SLAVE_PROCESSES
LOG_HISTORY 30
DEFAULT_TIMEZONE EST5EDT
EMAIL_SERVER
EMAIL_SERVER_ENCRYPTION NONE
EMAIL_SERVER_CREDENTIAL
EMAIL_SENDER
LAST_OBSERVED_EVENT
EVENT_EXPIRY_TIME
FILE_WATCHER_COUNT 0
CURRENT_OPEN_WINDOW WEDNESDAY_WINDOW
SCHEDULER_DISABLED TRUE
12 rows selected.
SQL> select * from dba_objects where object_name='SCHEDULER_DISABLED';
OWNER
------------------------------
OBJECT_NAME
--------------------------------------------------------------------------------
SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE
------------------------------ ---------- -------------- -------------------
CREATED LAST_DDL_ TIMESTAMP STATUS T G S NAMESPACE
--------- --------- ------------------- ------- - - - ----------
EDITION_NAME
------------------------------
SYS
SCHEDULER_DISABLED
81917 UNDEFINED
14-MAR-12 14-MAR-12 2012-03-14:23:11:58 VALID N N N 51
SQL>
SQL> DECLARE
2 x VARCHAR2(100);
3 BEGIN
4 dbms_scheduler.get_scheduler_attribute('DEFAULT_TIMEZONE', x);
5 dbms_output.put_line('DTZ: ' || x);
6 dbms_scheduler.get_scheduler_attribute('EVENT_EXPIRY_TIME', x);
dbms_output.put_line('EET: ' || x);
7 8 dbms_scheduler.get_scheduler_attribute('LOG_HISTORY', x);
9 dbms_output.put_line('LH: ' || x);
10 dbms_scheduler.get_scheduler_attribute('MAX_JOB_SLAVE_PROCESSES', x);
11 dbms_output.put_line('MJSP: ' || x);
12 dbms_scheduler.get_scheduler_attribute('SCHEDULER_DISABLED', x);
13 dbms_output.put_line('SCHEDULER_DISABLED: ' || x);
14 END;
15 /
DTZ: EST5EDT
EET:
LH: 30
MJSP:
SCHEDULER_DISABLED: TRUE
PL/SQL procedure successfully completed.
SQL> BEGIN
2 dbms_scheduler.create_job(
3 job_name => 'NULL_JOB',
4 job_type=>'PLSQL_BLOCK',
5 job_action=>' begin NULL; end;',
6 start_date => dbms_scheduler.stime,
7 repeat_interval => 'FREQ=MINUTELY;INTERVAL=1',
8 end_date => dbms_scheduler.stime+1,
9 enabled => TRUE,
10 auto_drop => FALSE,
11 comments => 'MacleanS JOB');
12 END;
13 /
SQL> select * from dba_scheduler_job_log where job_name='NULL_JOB';
no rows selected
SQL> /
no rows selected
SQL> exec dbms_scheduler.set_scheduler_attribute('SCHEDULER_DISABLED','FALSE');
PL/SQL procedure successfully completed.
SQL> select * from dba_objects where object_name='SCHEDULER_DISABLED';
no rows selected
SQL> select count(*) from dba_scheduler_job_log where job_name='NULL_JOB';
COUNT(*)
----------
1
SQL> select count(*) from dba_scheduler_job_log where job_name='NULL_JOB';
COUNT(*)
----------
2 |
|