2

我正在尝试使用 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'); 

任何建议表示赞赏,

4

0 回答 0