|
- select * from dba_scheduler_external_dests;
复制代码 | DESTINATION_NAME | HOSTNAME | PORT | IP_ADDRESS | ENABLED | COMMENTS | 1 | STATION199 | station199 | 1500 | 192.168.0.199 | TRUE | Registered on 04-AUG-18 05.55.04.276715 PM PRC |
- begin
- dbms_scheduler.create_database_destination(
- destination_name => 'db199',
- agent => 'station199',tns_name => 'orcl199');
- end;
复制代码- select * from dba_scheduler_db_dests;
复制代码 | OWNER | DESTINATION_NAME | CONNECT_INFO | AGENT | ENABLED | REFS_ENABLED | COMMENTS | 1 | SYS | DB199 | orcl199 | STATION199 | TRUE | TRUE | |
- begin
- dbms_scheduler.create_credential(credential_name => 'CREDENTIAL1',
- username =>'HR',
- password => 'hr');
- end;
- grant execute on credential1 to hr;
复制代码- grant all on db199 to hr;
复制代码- BEGIN
- dbms_scheduler.create_job(
- job_name => 'hr.job13',
- job_type => 'PLSQL_BLOCK',
- job_action => 'begin
- update employees set salary=salary+1 where employee_id=100;
- commit;
- end;',
- start_date => systimestamp at time zone 'Asia/Shanghai',
- repeat_interval => 'FREQ=SECONDLY;INTERVAL=30',
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'JOB13',
- auto_drop => FALSE,
- credential_name =>'"SYS"."CREDENTIAL1"' ,destination_name =>'db199' ,
- enabled => true);
- END;
复制代码
如果是一个存储过程,目的地那边要有这个存储过程吗:
在station199上建存储过程:
- BEGIN
- sys.dbms_scheduler.create_job(
- job_name => 'hr.job131',
- job_type => 'STORED_PROCEDURE',
- job_action => 'hr.procremotedb_win',
- start_date => systimestamp at time zone 'PRC',
- repeat_interval => 'FREQ=SECONDLY;INTERVAL=30',
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'job131',
- auto_drop => FALSE,
- enabled => FALSE,
- credential_name => 'sys.credential1',
- destination_name => 'db199');
- end;
复制代码- begin
- sys.dbms_scheduler.enable( '"HR"."JOB131"' );
- END;
复制代码
|
|