我正在尝试创建一个过程,该过程将对几个表执行某些更新,然后安排另一个过程以便稍后运行以将其还原。我在使用DBMS_SCHEDULER.CREATE_JOB时遇到了问题。我的代码如下所示:
create or replace procedure My_Procedure(p_DUNS in varchar2, p_PLUS_FOUR in varchar2) is
*SOME VARIABLES*
Begin
*DO SOME STUFF*
p_JOB_ACTION := 'begin run_other_procedure(' || p_VENDOR_ID || ', ' || p_CCRID || ', ' || nvl(to_char(p_INACTIVE_DATE),'null') || ',' || nvl(to_char(p_END_DATE),'null') || '); END;';
DBMS_SCHEDULER.CREATE_JOB(job_name => 'DEACTIVE_VENDOR_'||to_char(p_CCRID),
job_type => 'PLSQL_BLOCK',
JOB_ACTION => p_JOB_ACTION,
start_date => sysdate+1,
enabled => TRUE,
comments => 'Calls PLSQL once');
END;
我已经验证了程序的开始部分,但是当我添加CREATE_JOB时,我收到以下错误:
Error starting at line : 1 in command -
execute MY_PROCEDURE('140986105', null)
Error report -
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 124
ORA-06512: at "SYS.DBMS_SCHEDULER", line 271
ORA-06512: at "CGEXT.MY_PROCEDURE", line 63
ORA-06512: at line 1
27486. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a scheduler operation without the
required privileges.
*Action: Ask a sufficiently privileged user to perform the requested
operation, or grant the required privileges to the proper user(s).
当我拉出CREATE_JOB并自行运行时,我没有任何问题。
对此有何想法?
答案 0 :(得分:0)
在管理员权限下执行以下命令
sys as sysdba
grant execute on DBMS_SCHEDULER to USERNAME;
grant create job to USERNAME;