|
- select * from dba_scheduler_credentials;
- begin
- dbms_scheduler.create_credential(
- credential_name => 'credlocalfw',
- username => 'oracle',
- password => 'oracle');
- end;
- grant execute on credlocalfw to hr;
- begin
- dbms_scheduler.create_file_watcher(
- file_watcher_name => 'filewlocal',
- directory_path => '/home/oracle/dirfw',
- file_name => 'botang*.txt',
- credential_name => 'credlocalfw');
- end;
- ----------------------------------
- select * from dba_scheduler_file_watchers;
- grant execute on filewlocal to hr;
- grant execute on SYS.SCHEDULER_FILEWATCHER_RESULT to hr;
- grant create external job to hr;
- grant create job to hr;
- create table hr.tfilewlocal ( a varchar2(200) ) ;
- create or replace procedure hr.procfilewlocal ( p_1 SYS.SCHEDULER_FILEWATCHER_RESULT)
- is
- begin
- insert into tfilewlocal 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.progfilewlocal',
- program_type => 'STORED_PROCEDURE',
- program_action => 'HR.procfilewlocal',
- number_of_arguments => 1,
- enabled => false);
- end;
- begin
- dbms_scheduler.define_metadata_argument(
- program_name => 'HR.progfilewlocal',
- metadata_attribute => 'event_message',argument_position => 1 ) ;
- end;
- begin
- dbms_scheduler.enable('HR.progfilewlocal');
- end;
- begin
- dbms_scheduler.set_attribute('hr.jobfilewlocal','parallel_instances',true);
- end;
- select * from hr.tfilewlocal ;
- -------remote
- begin
- dbms_scheduler.create_credential(
- credential_name => 'credremotefw',
- username => 'botang',
- password => 'oracle');
- end;
- grant execute on credremotefw to hr;
- select * from dba_scheduler_external_dests;
- begin
- dbms_scheduler.create_file_watcher(
- file_watcher_name => 'filewremote',
- directory_path => 'c:\app\Administrator\dirfw',
- file_name => 'botang*.txt',
- credential_name => 'credremotefw',
- destination => 'STATION199');
- end;
-
- select * from dba_scheduler_file_watchers;
-
- grant execute on filewremote to hr;
-
- create table hr.tfilewremote ( a varchar2(200) ) ;
- create or replace procedure hr.procfilewremote ( p_1 SYS.SCHEDULER_FILEWATCHER_RESULT)
- is
- begin
- insert into tfilewremote 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.progfilewremote',
- program_type => 'STORED_PROCEDURE',
- program_action => 'HR.procfilewremote',
- number_of_arguments => 1,
- enabled => false);
- end;
- begin
- dbms_scheduler.define_metadata_argument(
- program_name => 'HR.progfilewremote',
- metadata_attribute => 'event_message',argument_position => 1 ) ;
- end;
- begin
- dbms_scheduler.enable('HR.progfilewremote');
- end;
- --EM---job
- BEGIN
- DBMS_SCHEDULER.CREATE_JOB(
- jOB_NAME=> 'hr.teacherjob1',
- PROGRAM_NAME=> 'hr.teacherprog1',
- EVENT_CONDITION => 'tab.user_data.file_size > 10',
- QUEUE_SPEC=> 'teacherfilew1',
- AUTO_DROP=> FALSE,
- ENABLED=> true);
- END;
- begin
- dbms_scheduler.set_attribute('hr.jobfilewremote','parallel_instances',true);
- end;
- select * from hr.tfilewremote;
-
- select * from hr.tfilewlocal;
- select * from dba_scheduler_file_watchers;
-
- -------------------------------
-
- select * from dba_scheduler_db_dests;
- begin
- dbms_scheduler.create_database_destination(
- destination_name => 'db199',
- agent => 'station199',tns_name => 'orcl199');
- end
-
- begin
- dbms_scheduler.create_credential(
- credential_name => 'credremotedb',
- username => 'hr',
- password => 'hr');
- end;
-
- grant execute on credremotedb to hr;
- BEGIN
- sys.dbms_scheduler.create_job(
- job_name => '"HR"."JOBREMOTEDB2"',
- job_type => 'STORED_PROCEDURE',
- job_action => '"HR"."PROC05317WIN"',
- start_date => systimestamp at time zone 'PRC',
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'jobremotedb',
- auto_drop => FALSE,
- enabled => FALSE,credential_name => 'sys.credremotedb',destination_name => 'db199');
- end;
- begin
- sys.dbms_scheduler.enable( '"HR"."JOBREMOTEDB2"' );
- END;
- BEGIN
- DBMS_SCHEDULER.CREATE_JOB(
- jOB_NAME=> 'hr.teacherjob1',
- PROGRAM_NAME=> 'hr.teacherprog1',
- EVENT_CONDITION => 'tab.user_data.file_size > 10',
- QUEUE_SPEC=> 'teacherfilew1',
- AUTO_DROP=> FALSE,
- ENABLED=> true);
- END;
- EGIN
- sys.dbms_scheduler.create_job(
- job_name => '"HR"."JOBFILEW1"',
- program_name => '"HR"."PROGFILEW1"',
- event_condition => 'tab.user_data.file_size > 10',
- queue_spec => '"SYS"."FILEW1"',
- start_date => systimestamp at time zone 'Asia/Shanghai',
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'jobfilew1',
- auto_drop => FALSE,
- enabled => TRUE);
- END;
- begin
- dbms_scheduler.set_attribute('hr.jobfilew1','parallel_instances',true);
- end;
- ---
- grant execute on SYS.SCHEDULER_FILEWATCHER_RESULT to hr;
复制代码
|
|