|
能够记住事件本身(文件属性)的filewatcher:
--hr
- select * from user_sys_privs ;
复制代码 HR CREATE EXTERNAL JOB NO NO
HR CREATE EVALUATION CONTEXT NO NO
HR CREATE VIEW NO NO
HR UNLIMITED TABLESPACE NO NO
HR CREATE DATABASE LINK NO NO
HR CREATE RULE SET NO NO
HR CREATE JOB NO NO
HR CREATE SEQUENCE NO NO
HR CREATE RULE NO NO
HR CREATE SESSION NO NO
HR ALTER SESSION NO NO
HR CREATE SYNONYM NO NO
- [root@classroom 4]# cd /usr/lib64
- [root@classroom lib64]# ls -l libpam*
- lrwxrwxrwx 1 root root 17 12月 7 2018 libpamc.so.0 -> libpamc.so.0.82.1
- -rwxr-xr-x 1 root root 17048 12月 7 2018 libpamc.so.0.82.1
- lrwxrwxrwx 1 root root 21 12月 7 2018 libpam_misc.so.0 -> libpam_misc.so.0.82.1
- -rwxr-xr-x 1 root root 16704 12月 7 2018 libpam_misc.so.0.82.1
- lrwxrwxrwx 1 root root 16 12月 7 2018 libpam.so.0 -> libpam.so.0.84.2
- -rwxr-xr-x 1 root root 74600 12月 7 2018 libpam.so.0.84.2
- [root@classroom lib64]# ln -s libpam.so.0.84.2 libpam.so
- [root@classroom lib64]#
复制代码- begin
- dbms_scheduler.create_credential('credential10','oracle','spoto_oracle_123');
- end;
- /
复制代码- select * from dba_scheduler_credentials;
复制代码 SYS CREDENTIAL13 HR
SYS CREDENTIAL10 oracle
这是一个总队列,当你做你自己第一个filewathcer时,他就启动。我们的filewatcher都是它的实例。
- begin
- dbms_scheduler.create_file_watcher(
- file_watcher_name => 'filewatcher1',
- directory_path => '/home/oracle/myfile',
- file_name => 'botang*.txt',
- credential_name => 'credential10');
- end;
- /
- select * from dba_scheduler_file_watchers;
复制代码 SYS FILEWATCHER1 TRUE /home/oracle/myfile botang*.txt SYS CREDENTIAL10 0 06-DEC-20 05.28.55.707615000 PM +08:00
- grant execute on filewatcher1 to hr;
- grant execute on SYS.SCHEDULER_FILEWATCHER_RESULT to hr;
- grant execute on credential10 to hr;
复制代码
- create table hr.tfilewatcher1 ( a varchar2(200) ) ;
- create or replace procedure hr.procfilewatcher ( p_1 SYS.SCHEDULER_FILEWATCHER_RESULT)
- is
- begin
- insert into hr.tfilewatcher1 values ( to_char( p_1.file_timestamp,'YYYY-MM-DD:HH24:MI:SS') ||' '
- ||p_1.directory_path||' '
- ||p_1.actual_file_name||' '
- ||p_1.file_size ) ;
- commit;
- end;
- /
- begin
- dbms_scheduler.create_program(
- program_name => 'HR.program11',
- program_type => 'STORED_PROCEDURE',
- program_action => 'HR.procfilewatcher',
- number_of_arguments => 1,
- enabled => false);
- end;
- /
- begin
- dbms_scheduler.define_metadata_argument(
- program_name => 'HR.program11',
- metadata_attribute => 'event_message',argument_position => 1 ) ;
- end;
- /
- begin
- dbms_scheduler.enable('HR.program11');
- end;
- /
复制代码- BEGIN
- DBMS_SCHEDULER.CREATE_JOB(
- jOB_NAME=> 'hr.job11',
- PROGRAM_NAME=> 'hr.program11',
- EVENT_CONDITION => 'tab.user_data.file_size > 10',
- QUEUE_SPEC=> 'sys.filewatcher1',
- AUTO_DROP=> FALSE,
- ENABLED=> true);
- END;
复制代码
- begin
- dbms_scheduler.set_attribute('hr.job11','parallel_instances',true);
- end;
- /
复制代码
|
|