11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 3 ■ DATABASE ADMINISTRATION 165SQL> exec dbms_scheduler.create_credential('testcredential','salapati','sammyy1');In the example, the database creates a credential named testcredential, with theusername salapati and password sammyy1. You can grant any user in the database theprivilege to use a credential by using the grant statement, as shown here:SQL> grant execute on testcredential to newuser;Once you create a credential, you can specify the credential for any external job by usingthe set_attribute procedure, as we’ll show in our example in this section. You can viewall the credentials in a database by querying the DBA_SCHEDULER_CREDENTIALS view.2. You must use the destination attribute when creating a remote external job to specifythe destination host and port. You can find the port number, which is the port on whichthe Scheduler agent listens, by viewing the file schagent.conf, located in the Scheduleragent home directory (on the remote host).The following example shows how to create a remote external job:begindbms_scheduler.create_job(job_name=> 'deletelogs',job_type=> 'executable',job_action=> '/u01/app/oracle/deletelogs',repeat_interval => 'freq=daily; byhour=23',enabled=> false);dbms_scheduler.set_attribute(' deletelogs', 'credential_name','testcredential');dbms_scheduler.set_attribute ('deletelogs', 'destination', 'app123:12345');dbms_scheduler.enable(' deletelogs');end;The create_job procedure shown here creates a remote external job named deletelogs. Theset_attribute procedure sets the credential name and the destination (host and port number)for the external job. Note that you must enable the new remote external job deletejobs using theenable procedure after setting the credential and destination attributes.Scheduler Support for Data GuardIf you’re using a physical standby database, then all Scheduler-related changes made on theprimary database are applied to the physical standby database, like any other database change.For primary database and logical standby databases, you can now specify that a job can runonly if the database is in the primary database role or only when the database is in the logicalstandby database role.Use the set_attribute procedure of the DBMS_SCHEDULER package to set the job attributedatabase_role to either primary or logical standby. Upon a swtichover or a failover, the Schedulerwill automatically run the job specific to the role. In the case of a failover, the job event logwill show all successful DML changes on the primary database until the time of the failover.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!