Bo's Oracle Station

查看: 1580|回复: 0

第78和79次:2014-12-28上下午

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2014-12-28 12:10:02 | 显示全部楼层 |阅读模式
本帖最后由 botang 于 2014-12-30 12:47 编辑
  1. select  * from dba_scheduler_credentials;

  2. select  * from dba_tab_privs tp where tp.grantee='HR';

  3. begin
  4.    dbms_scheduler.create_file_watcher(
  5.        file_watcher_name => 'filewatcher1',
  6.        directory_path => '/home/oracle/dir1',
  7.        file_name => 'myfile*',
  8.        credential_name => 'credential1');
  9. end;

  10. select  * from dba_scheduler_file_watchers;

  11. grant execute on filewatcher1  to hr;

  12. grant execute on SYS.SCHEDULER_FILEWATCHER_RESULT   to hr;

  13. select * from dba_sys_privs sp where sp.grantee='HR';


  14. create table hr.t05317_fw   ( a  varchar2(200)  ) ;



  15. create or replace procedure hr.procfilewatcher (p_1  SYS.SCHEDULER_FILEWATCHER_RESULT)
  16. is
  17. begin
  18.   insert into     hr.t05317_fw   values ( to_char( p_1.file_timestamp,'YYYY-MM-DD:HH24:MI:SS') ||' '
  19.                                                       ||p_1.directory_path||'  '
  20.                                                       ||p_1.actual_file_name||'       '
  21.                                                       ||p_1.file_size  ) ;
  22.   commit;
  23. end;


  24. begin
  25.     dbms_scheduler.create_program(
  26.      program_name => 'HR.progfilewatcher',
  27.      program_type => 'STORED_PROCEDURE',
  28.      program_action => 'HR.procfilewatcher',
  29.      number_of_arguments => 1,
  30.      enabled => false);
  31. end;

  32. select  * from dba_scheduler_program_args  a where  a.owner='HR';


  33. begin
  34.    dbms_scheduler.define_metadata_argument(
  35.    program_name => 'HR.progfilewatcher',
  36.    metadata_attribute => 'event_message',argument_position => 1 ) ;
  37. end;

  38. select  * from dba_scheduler_program_args  a where  a.owner='HR';


  39. begin
  40.   dbms_scheduler.enable('HR.progfilewatcher');
  41. end;


  42. BEGIN
  43. sys.dbms_scheduler.create_job(
  44. job_name => '"HR"."JOB_B"',
  45. program_name => '"HR"."PROGFILEWATCHER"',
  46. event_condition => null,
  47. queue_spec => '"SYS"."FILEWATCHER1"',
  48. start_date => systimestamp at time zone 'Asia/Shanghai',
  49. job_class => '"DEFAULT_JOB_CLASS"',
  50. comments => 'JOB_B',
  51. auto_drop => FALSE,
  52. enabled => TRUE);
  53. END;


  54. begin
  55.    dbms_scheduler.set_attribute('hr.job_b','parallel_instances',true);
  56. end;


  57. select  * from  hr.t05317_fw  ;
复制代码
  1. select  * from dba_scheduler_notifications;

  2. begin
  3.    DBMS_SCHEDULER.SET_ATTRIBUTE('hr.job_c', 'raise_events', DBMS_SCHEDULER.JOB_all_events);
  4. end;

  5. select *   from   dba_scheduler_jobs j  where  j.job_name='JOB_C' ;

  6. BEGIN
  7. DBMS_SCHEDULER.add_job_email_notification (
  8.   job_name   =>  'hr.job_c',
  9.   recipients =>  'zhang3@example.com',
  10.   events     =>  'job_all_events');
  11. END;


  12. -----

  13. select s.USERNAME , s.TERMINAL, s.RESOURCE_CONSUMER_GROUP    from gv_$session   s where terminal='pts/5';

  14. select  * from dba_scheduler_job_classes;


  15. BEGIN
  16. sys.dbms_scheduler.create_job(
  17. job_name => '"HR"."JOB_F"',
  18. job_type => 'PLSQL_BLOCK',
  19. job_action => 'declare
  20.   v_1  number;
  21. begin
  22.   select count(*)  into v_1 from  tbig a  , tbig b;
  23. end;
  24. ',
  25. start_date => systimestamp at time zone 'Asia/Shanghai',
  26. job_class => '"JOBCLASS1"',
  27. comments => 'JOB_F',
  28. auto_drop => FALSE,
  29. enabled => TRUE);
  30. END;

  31. grant execute on jobclass1 to hr;

  32. select  * from dba_tab_privs tp where tp.grantee='HR';

  33. select  * from dba_scheduler_running_jobs;

复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-22 11:05 , Processed in 0.034408 second(s), 24 queries .

快速回复 返回顶部 返回列表