Submit a job and run : DBMS_JOB « System Packages « Oracle PL/SQL Tutorial






SQL>
SQL> set echo on
SQL>
SQL> create table t ( msg varchar2(20), cnt int );

Table created.

SQL>
SQL> insert into t select 'from SQL*PLUS', count(*) from session_roles;

1 row created.

SQL>
SQL> variable n number
SQL>
SQL> exec dbms_job.submit(:n,'insert into t select ''from job'', count(*) from session_roles;');

PL/SQL procedure successfully completed.

SQL>
SQL> print n

         N
----------
       181

SQL>
SQL> exec dbms_job.run(:n);

PL/SQL procedure successfully completed.

SQL>
SQL> select * from t;

MSG                         CNT
-------------------- ----------
from SQL*PLUS                12
from job                      0

SQL> drop table t;

Table dropped.

SQL>








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: