|
|
Creating a Job that Executes a PL/SQL Block
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. |
Select the Jobs link.
|
|
| 2. |
Click Create to create a new job.
|
|
| 3. |
Enter the following information, then click OK. Name: ALTER_INDX001
|
|
| 4. |
Your job was executed. Click the Run History tab. If you do not see your job, click Refresh.
|
|
| 5. |
You see the job ALTER_INDX001 completed successfully. Click on the job to see the job execution details.
|
|
| 6. |
Now you are ready to create a job that executes a PL/SQL procedure. Click the database breadcrumb at the top of the window.
|
|
In this case, you will first create a PL/SQL procedure and then create a job that will point to the procedure which will execute when the job is executed. You will perform the following:
| Creating a Procedure | ||
| Create a Job that uses the PL/SQL Procedure | ||
Perform the following:
| 1. |
Select the Procedures link.
|
|
| 2. |
Click Create.
|
|
| 3. |
Enter the following information, then click OK. Name: COALESCE_INDX001
|
|
| 4. |
Click your Database breadcrumb.
|
|
Now you can create the job. Perform the following:
| 1. |
Select the Jobs link.
|
|
| 2. |
Click Create.
|
|
| 3. |
Enter the following information, then click Change Command Type. Name: ALTER_INDX_PROC001
|
|
| 4. |
Select In-line Program: Stored Procedure and click the search light.
|
|
| 5. |
Select COALESCE_INDX001 from the list and click Select.
|
|
| 6. |
Click OK.
|
|
| 7. |
Select the Schedule tab.
|
|
| 8. |
Make sure Start is set to Immediately and click OK.
|
|
| 9. |
Click the Disabled tab.
|
|
| 10. |
Select ALTER_INDX_PROC001.
|
|
| 11. |
Click Yes for Enabled and click Apply.
|
|
| 12. |
Select the Scheduler Jobs breadcrumb.
|
|
| 13. |
Click the Run History tab.
|
|
| 14. |
Notice that your job ran successfully. Select ALTER_INDX_PROC001.
|
|
| 15. |
You may view the logged history of the job. When done, click your Database breadcrumb.
|
|
At this point you want to create a schedule that will run at 11:00PM every night for the next year. Perform the following:
| 1. |
Select the Schedules link.
|
|
| 2. |
Click Create to create a new schedule.
|
|
| 3. |
Enter the following information, then click OK. Name: SCHED001
|
|
| 4. |
Click the Database breadcrumb.
|
|
You would like to associated the saved schedule you just created, to a job. Perform the following:
| 1. |
Select the Jobs link.
|
|
| 2. |
Click the Disabled tab.
|
|
| 3. |
Select ALTER_INDX001.
|
|
| 4. |
Click Yes for Enabled and then click the Schedule tab.
|
|
| 5. |
Select the Schedule Type Use Pre-defined Schedule, then click on the search light to select a schedule.
|
|
| 6. |
Select SCHED001 and click Select.
|
|
| 7. |
Click Apply.
|
|
| 8. |
Click the Scheduler Jobs breadcrumb.
|
|
| 9. |
Click on the Scheduled tab.
|
|
| 10. |
Click Refresh.
|
|
| 11. |
Your scheduled job appears.
|
|
Programs are used to provide a level of abstration. The action is specified in the program and not the job itself. The jobs then point to the program. If, for example, the shell script name or location changes, each job does not have to be changed, only one program. In this section, you will create a program and two jobs that each point to the program. You will perform the following:
| Creating a Program | ||
| Creating a Job that Uses the Program | ||
| Sharing the Program with Another User | ||
| Creating a Job that Resides in Another Schema that uses the Program | ||
Perform the following:
| 1. |
Make sure you have copied the files from the prerequisites for this lesson and placed them in your working directory. From the Administration tab, click Programs.
|
|
| 2. |
Click Create.
|
|
| 3. |
Enter the following information, then click Add Another Row . Name: LOADDATA
|
|
| 4. |
Enter the following information, then click OK. Name: filename
|
|
| 5. |
Your program has been created. Click your database breadcrumb.
|
|
Now you will create a job that uses the program you just created. Perform the following:
| 1. |
Click Jobs.
|
|
| 2. |
Click Create.
|
|
| 3. |
Enter the following information, then click Change Command Type. Name: LOADDATA_JOB1
|
|
| 4. |
Select Program Name and click the search light.
|
|
| 5. |
Select LOADDATA from the list and click Select.
|
|
| 6. |
Click OK.
|
|
| 7. |
Scroll down to the Arguments heading.
|
|
| 8. |
Select User defined from the drop down list for the Option column. Enter /<wkdir path>/loaddata1.dat in the Value column and click OK.
|
|
| 9. |
Your job has been submitted. Click Run History tab.
|
|
| 10. |
Your job was run successfully. The next section requires you to be logged in as a super user. Click Logout.
|
|
In order for another user to use the program, the user who created the program or the super user needs to share it. Perform the following:
| 1. |
Click Login.
|
|
| 2. |
Login as system/<password>
and click Login. Note: the user HR can grant the user OE access
to the program loaddata. You are login as system because you also want
to grant the user OE the CREATE JOB privilege at the same time and only
a super user can perform that task.
|
|
| 3. |
Click Administration tab.
|
|
| 4. |
Click Users.
|
|
| 5. |
Enter OE and click Go.
|
|
| 6. |
Select OE.
|
|
| 7. |
Click System Privileges tab.
|
|
| 8. |
You need to add some privileges, click Modify.
|
|
| 9. |
Select CREATE JOB and SELECT ANY DIRECTORY from the list and click Move. Then click OK.
|
|
| 10. |
Now you need to add EXECUTE privilege for the LOADDATA program you created previously. Click Object Privileges.
|
|
| 11. |
Select Programs from the Select Object Type drop down list and click Add.
|
|
| 12. |
Select the Search light next to the Select Programs Objects box.
|
|
| 13. |
Select HR from the Schema drop down list box and click Go.
|
|
| 14. |
Check LOADDATA and click Select.
|
|
| 15. |
Select EXECUTE from the list of privileges and click Move. Then click OK.
|
|
| 16. |
Click Apply.
|
|
| 17. |
The user OE has been updated. You now need to login as OE. Click Logout.
|
|
In order for another user to use the program, the super user needs to give them access. Perform the following:
| 1. |
Click Login.
|
|
| 2. |
Login as OE/<password> and click Login.
|
|
| 3. |
Click Administration tab.
|
|
| 4. |
Click Jobs.
|
|
| 5. |
Click Create.
|
|
| 6. |
Enter the following information, then click Change Command Type. Name: LOADDATA_JOB2
|
|
| 7. |
Select Program Name and click the search light.
|
|
| 8. |
Select LOADDATA from the list and click Select.
|
|
| 9. |
Click OK.
|
|
| 10. |
Scroll down to the Arguments heading. Select User defined from the drop down list for the Option column. Enter /<wkdir path>/loaddata1.dat in the Value column and click OK.
|
|
| 11. |
Your job has been submitted. Click Run History tab.
|
|
| 12. |
Your job ran successfully using the same program.
|
|
|
|
|
|
|