Submit a job and query the user_jobs : DBMS_JOB « System Packages « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » System Packages » DBMS_JOB 
31. 11. 4. Submit a job and query the user_jobs
SQL>
SQL> create or replace procedure analyze_my_tables
  2  as
  3  begin
  4      for x in select table_name from user_tables )
  5      loop
  6          execute immediate
  7              'analyze table ' || x.table_name || ' compute statistics';
  8      end loop;
  9  end;
 10  /

Procedure created.

SQL>
SQL> declare
  2      l_job number;
  3  begin
  4      dbms_job.submitjob       => l_job,
  5                       what      => 'analyze_my_tables;',
  6                       next_date => trunc(sysdate)+1+3/24,
  7                       interval  => 'trunc(sysdate)+1+3/24' );
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL>
SQL> select job, to_char(sysdate,'dd-mon'),
  2                    to_char(next_date,'dd-mon-yyyy hh24:mi:ss'),
  3                    interval, what
  4  from user_jobs
  5  /

       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------
        21 25-jul 01-jan-4000 00:00:00
SYSDATE + (10/(24*60*60))
P_RUN_INSERT;

        22 25-jul 01-jan-4000 00:00:00
SYSDATE + (10/(24*60*60))
P_RUN_INSERT;

       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------

        41 25-jul 26-jul-2008 03:00:00
TRUNC(SYSDATE+13/24
GATHER_MY_STATS;

        61 25-jul 25-jul-2008 19:34:32
SYSDATE + 1/24

       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------
LOG_SOURCE;

       101 25-jul 01-jan-4000 00:00:00
SYSDATE + (10/(24*60*60))
P_RUN_INSERT;

        82 25-jul 26-jul-2008 03:00:00

       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------
trunc(sysdate)+1+3/24
analyze_my_tables;

       121 25-jul 01-jan-4000 00:00:00
SYSDATE + (10/(24*60*60))
P_RUN_INSERT;


       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------
       122 25-jul 01-jan-4000 00:00:00
SYSDATE + (10/(24*60*60))
P_RUN_INSERT;

       141 25-jul 25-jul-2008 21:18:41
TRUNC(SYSDATE+13/24
GATHER_MY_STATS;

       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------

       161 25-jul 25-jul-2008 19:46:13
SYSDATE + 1/24
LOG_SOURCE;

       162 25-jul 25-jul-2008 19:49:44
SYSDATE + 1/24

       JOB TO_CHA TO_CHAR(NEXT_DATE,'D
---------- ------ --------------------
INTERVAL
--------------------------------------------------------------------------------
WHAT
--------------------------------------------------------------------------------
LOG_SOURCE;

       182 25-jul 26-jul-2008 03:00:00
trunc(sysdate)+1+3/24
analyze_my_tables;


12 rows selected.
31. 11. DBMS_JOB
31. 11. 1. DBMS_JOB demonstration
31. 11. 2. DBMS_JOB.SUBMIT
31. 11. 3. Submit a job and run
31. 11. 4. Submit a job and query the user_jobs
31. 11. 5. Job number
31. 11. 6. Use dbms_job.submit to call 'execute immediate'
31. 11. 7. Submit job to change password
31. 11. 8. Schedule the procedure to run now and every night at 3 AM:
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.