Oracle DBMS_SCHEDULER error: ORA-27369. exit code 7 - oracle

I try to run external script with Oracle Database whit DBMS_SCHEDULER.
I created a job:
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB( job_name => 'MODPY_JOB',
job_type => 'EXECUTABLE',
job_action => 'C:\Windows\System32\cmd.exe',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Job to call batch script on Windows',
auto_drop => FALSE,
number_of_arguments => 3,
enabled => FALSE);
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'MODPY_JOB', argument_position => 1, argument_value => '/q');
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'MODPY_JOB', argument_position => 2, argument_value => '/c');
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'MODPY_JOB', argument_position => 3, argument_value => 'C:\m.bat >nul');
SYS.DBMS_SCHEDULER.ENABLE( 'MODPY_JOB' );
END;
I tried to run it:
BEGIN
DBMS_SCHEDULER.RUN_JOB(
JOB_NAME => 'MODPY_JOB',
USE_CURRENT_SESSION => TRUE);
END;
I got this error:
ORA-27370: job slave failed to launch a job of type EXECUTABLE
ORA-27300: OS system dependent operation:accessing job scheduler service failed with status: 2
ORA-27301: OS failure message: No such file or directory
ORA-27302: failure occurred at: sjsec 6a
ORA-27303: additional information: The system cannot find the file specified.
ORA-06512: at "SYS.DBMS_ISCHED", line 209.
ORA-06512: at "SYS.DBMS_SCHEDULER", line 594.
ORA-06512: at line 2.
27370. 00000 - "job slave failed to launch a job of type EXECUTABLE"
*Cause: The scheduler ran into an error when the job slave tried to start
a job of type EXECUTABLE. The rest of the error stack will provide
more detailed information on what the exact problem was.
*Action: Correct the problem specified in the error stack and reschedule
the job.
I made a credential to solve the problem:
begin
dbms_scheduler.create_credential(
CREDENTIAL_NAME => 'NAME',
USERNAME => 'user',
PASSWORD => 'pswd',
WINDOWS_DOMAIN => 'localdomain');
end;
After that, I gave credential details to the job:
begin
dbms_scheduler.set_attribute('MODPY_JOB','credential_name','NAME');
end;
/
When I run try to run the job again, I got this error:
Error report -
ORA-27369: job of type EXECUTABLE failed with exit code: 7 !##--!##7##!--##!
ORA-06512: at "SYS.DBMS_ISCHED", line 209.
ORA-06512: at "SYS.DBMS_SCHEDULER", line 594.
ORA-06512: at line 2.
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.
I tried to run this on Windows OS, and I got Oracle Database 12.
Where is the problem? How can I fix this and run external file with oracle?

Related

Procedure to move oracledb export to s3 bucket fails when ran in a job

Job fails with:
ORA-29481: Implicit results cannot be returned to client.
ORA-06512: at "SYS.DBMS_SQL", line 2832
ORA-06512: at "SYS.DBMS_SQL", line 2826
ORA-06512: at "owner.SEND_TO_S3", line 8
ORA-06512: at line 1
I can run the procedure manually(BEGIN SEND_TO_S3; END;) without errors and the db exports
show up in the s3 bucket.
****Oracle Job
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'SEND_EXP_TO_S3_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN SEND_TO_S3; END;',
start_date => SYSTIMESTAMP,
enabled => TRUE,
repeat_interval => 'freq=weekly; byday=mon; byhour=20; byminute=40; bysecond=0;');
END;
****Oracle procedure
(If there some other way than to use a refcursor that might solve this issue as well)
CREATE OR REPLACE PROCEDURE send_to_s3
AS
rc sys_refcursor;
BEGIN
open rc for
SELECT
rdsadmin.rdsadmin_s3_tasks.upload_to_s3(
p_bucket_name => 'bucket/name',
p_prefix => 'EXP',
p_s3_prefix => '',
p_directory_name => 'DATA_PUMP_DIR') `your text`
AS TASK_ID FROM DUAL;
DBMS_SQL.RETURN_RESULT(rc);
END send_to_s3;
****The oracle error points to an outdated client but I have the latest client and I'm
not sure the scheduler uses a client.
Is there a way to get this job running correctly?

Insufficient privilege DBMS_SCHEDULER job

I have created a job in Oracle using following scheduler -
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'MY_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN my_pkg.pull_data(''Y''); END;',
start_date => '31-AUG-21 07.00.00 PM America/New_York',
repeat_interval => 'freq=daily; byminute=0; bysecond=0;',
enabled => TRUE);
END;
/
When I am running job manually using below code -
BEGIN
DBMS_SCHEDULER.RUN_JOB(
JOB_NAME => 'MY_JOB',
USE_CURRENT_SESSION => FALSE);
END;
The job is running as expected. However, scheduled same jobs are failed again and again with below error.
ORA-01031: insufficient privileges ORA-06512: at "SCOTT.MY_PKG", line 246 ORA-06512: at line 1
Any suggestion, what I am doing wrong? I think I have sufficient privileges.
Edit - If I call, individual procedure which is used in the job, it's working as expected. I have checked the line 246, which is a select statement from a table in the same schema as job, proc and other tables used by the proc.
BEGIN my_pkg.pull_data('Y'); END;

Data Pump import fails with "job does not exist"

Can anyone help with this problem? I'm trying to use datapump to load a dump file created but whenever I try, I get the following code:
DECLARE
hdnl NUMBER;
status VARCHAR2(20);
BEGIN
hdnl := dbms_datapump.open (operation => 'IMPORT', job_mode => 'TABLE', version => 'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'import.log', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
DBMS_DATAPUMP.ADD_FILE(handle => hdnl, filename => 'latest.dmp', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.START_JOB(handle => hdnl);
DBMS_DATAPUMP.WAIT_FOR_JOB(hdnl,status);
end;
/
I'm getting this error:
Error report -
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 1852
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6793
ORA-06512: at line 5
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing,
is not executing on the instance where the operation was
attempted, or that does not have a valid Master Table.
Refer to any following error messages for clarification.
*Action: Start a new job, or attach to an existing job that has a
valid Master Table.
Any idea?
Regards

SQL Exception ORA-27478: job "JOB_MIG_17602" is running during DBMS_SCHEDULER.run_job

Getting the below exception when trying to run multiple jobs in parallel. This occurs intermittently.
The point of failure is DBMS_SCHEDULER.run_job
SQL Exception ORA-27478: job "JOB_MIG_17602" is running
"ORA-06512: at "SYS.DBMS_ISCHED", line 196
ORA-06512: at "SYS.DBMS_SCHEDULER", line 48
Description of the Job:
The job invokes a stored procedure which updates a table. The same stored procedure is invoked by different instances of the job created using unique job name.
Below are the steps to run the jobs:
DBMS_SCHEDULER.create_job(
job_name => l_job_name,
job_type => 'STORED_PROCEDURE',
job_action => i_chunk_processor_name,
number_of_arguments => 2,
enabled => FALSE,
auto_drop => FALSE
);
DBMS_SCHEDULER.set_job_argument_value(job_name => l_job_name, argument_position => 1, argument_value => i_user_id);
DBMS_SCHEDULER.set_job_argument_value(job_name => l_job_name, argument_position => 2, argument_value => i_chunk_id);
DBMS_SCHEDULER.enable(l_job_name);
COMMIT;
DBMS_SCHEDULER.run_job(job_name => l_job_name, use_current_session => FALSE);
Enabling a job means it is eligible for execution. So if the scheduler coordinator picks it up and starts it before you get to the "run_job" command, then you'll get the error, eg
SQL> begin
2 DBMS_SCHEDULER.create_job(
3 job_name => 'XXX',
4 job_type => 'PLSQL_BLOCK',
5 job_action => 'begin dbms_lock.sleep(60); end;',
6 enabled => FALSE,
7 auto_drop => FALSE
8 );
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> exec DBMS_SCHEDULER.enable('XXX');
PL/SQL procedure successfully completed.
-- I wait for a few seconds
--
SQL> exec DBMS_SCHEDULER.run_job(job_name => 'XXX', use_current_session => FALSE);
BEGIN DBMS_SCHEDULER.run_job(job_name => 'XXX', use_current_session => FALSE); END;
*
ERROR at line 1:
ORA-27478: job "MCDONAC"."XXX" is running
ORA-06512: at "SYS.DBMS_ISCHED", line 238
ORA-06512: at "SYS.DBMS_SCHEDULER", line 568
ORA-06512: at line 1
If you are enabling it, you should not need an explicit run_job request.

Run exe using trigger from Oracle database

I am trying to run exe from oracle database.
I want to fire a trigger on insert or updation of a table. Once table is updated i have to run my exe which is in my D drive.
I have tried scheduler but it gives error.
my code is as follows:
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'program_name',
program_type => 'EXECUTABLE',
program_action => 'D:/myproc.exe',
enabled => TRUE,
comments => 'run exe'
);
END;
/
I am getting following error
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 5
ORA-06512: at "SYS.DBMS_SCHEDULER", line 36
ORA-06512: at line 2
I have one more question.
Which is best method to run exe? from database or from code?
Thanks in advance
You could schedule the script using DBMS_SCHEDULER.
Depending on your OS(below example in Windows) you could something like this:
BEGIN
dbms_scheduler.create_job('MY_JOB',
job_action=>'C:\WINDOWS\SYSTEM32\CMD.EXE',
number_of_arguments=>3,
job_type=>'executable',
start_date => SYSTIMESTAMP,
repeat_interval => 'freq=hourly; byminute=0,30; bysecond=0;',
end_date => NULL,
enabled=> false);
dbms_scheduler.set_job_argument_value('MY_JOB',1,'/q');
dbms_scheduler.set_job_argument_value('MY_JOB',2,'/c');
dbms_scheduler.set_job_argument_value('MY_JOB',3, 'D:/my_sql.bat.bat');
dbms_scheduler.enable('MY_JOB');
END;
/
Now your my_sql.bat would look like:
sqlplus user#sid/password #D:\scripts\script.sql
exit

Resources