我正在尝试使用Oracle设置一个计划的外部作业来调用批处理文件。我在网上发现了很多关于这个问题的材料,但是我遗漏了一些东西。
我在SQL Developer中运行我的PL / SQL(但我也在SQLPlus中尝试过)。我在输出窗口中得到的错误如下。
Error starting at line 7 in command:
exec dbms_scheduler.run_job('my_job')
Error report:
ORA-27369: job of type EXECUTABLE failed with exit code: The storage control blocks were destroyed.
ORA-06512: at "SYS.DBMS_ISCHED", line 185
ORA-06512: at "SYS.DBMS_SCHEDULER", line 486
ORA-06512: at line 1
27369. 00000 - "job of type EXECUTABLE failed with exit code: %s"
*Cause: A problem was encountered while running a job of type EXECUTABLE.
The cause of the actual problem is identified by the exit code.
*Action: Correct the cause of the exit code and reschedule the job.
我在dba_scheduler_job_run_details中收到的错误如下。
"EXTERNAL_LOG_ID="job_167045_46155",
ORA-27369: job of type EXECUTABLE failed with exit code: The storage control blocks were destroyed.
STANDARD_ERROR="Launching external job failed: Invalid username or password""
我认为这是一种许可问题,无论是我的批处理文件位于何处。我正在尝试将该工作作为维护帐户运行。如果我使用Windows cmd行“runas”命令并直接运行我的批处理文件,一切都很好。如果我运行Oracle,它不会。我尝试了不同的帐户,例如管理员帐户,但它没有任何区别。
我用来创建我的凭证/工作的代码如下。
exec dbms_scheduler.create_credential( credential_name => 'oracle_cred', username => 'user', password => 'password', windows_domain => 'domain' );
DBMS_SCHEDULER.create_job ('my_job',
job_action => 'C:\WINDOWS\SYSTEM32\CMD.EXE',
number_of_arguments => 2,
start_date=> sysdate+1,
auto_drop=>FALSE,
job_type => 'executable',
enabled => FALSE
);
DBMS_SCHEDULER.set_job_argument_value ('my_job', 1, '/C');
DBMS_SCHEDULER.set_job_argument_value ('my_job', 2, 'C:\maintenance\audit.bat');
dbms_scheduler.set_attribute('my_job', 'credential_name', 'oracle_cred');
DBMS_SCHEDULER.enable('my_job');
感谢任何建议,
MJ