dbms_job和dbms_ijob
工作中可能遇到这样的情况,在A用户下有一个不用的job,但是dba不知道A用户的密码,怎么删除这个job呢。
相信大部分人都会尝试在sys用户下用dbms_job.remove()命令去删除它,但是会报错
sys用户下
SQL> exec dbms_job.remove(70);
BEGIN dbms_job.remove(70); END;
*
ERROR at line 1:
ORA-23421: job number 70 is not a job in the job queue
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_IJOB", line 680
ORA-06512: at "SYS.DBMS_JOB", line 174
ORA-06512: at line 1
还是在sys用户下,使用dbms_ijob.remove()就可以删除
SQL> exec dbms_ijob.remove(70);
PL/SQL procedure successfully completed.
那么,到底dbms_job和dbms_ijob到底怎么用,彼此有什么区别呢?下面用实验证明。
一、sys用户使用dbms_ijob为hou用户创建job
1.查看dbms_ijob.submit的书写格式
sys用户下desc dbms_ijob
PROCEDURE SUBMIT
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
JOB BINARY_INTEGER IN
LUSER VARCHAR2 IN --> Login user when the job was submitted
PUSER VARCHAR2 IN --> User whose default privileges apply to this job
CUSER VARCHAR2 IN --> schema_user
NEXT_DATE DATE IN
INTERVAL VARCHAR2 IN
BROKEN BOOLEAN IN
WHAT VARCHAR2 IN -->procedure
NLSENV VARCHAR2 IN
ENV RAW IN
2.hou用户下创建一个简单存储过程
SQL> conn hou/
Enter password:
Connected.
SQL> create table test(a date);
Table created.
SQL> create or replace procedure pro_insert_date as
begin
insert into test values(sysdate);
end;
/ 2 3 4 5
Procedure created.
3.sys用户为hou创建5号job
SQL> conn / as sysdba
Connected.
SQL> begin
dbms_ijob.submit(5,'HOU','HOU','HOU',
to_date('2012-09-29 12:30:00','YYYY-MM-DD HH24:MI:SS'),'sysdate+1',false,'pro_insert_date;',
'NLS_LANGUAGE=''SIMPLIFIED CHINESE'' NLS_TERRITORY=''CHINA'' NLS_CURRENCY=''¥'' NLS_ISO_CURRENCY=''CHIN