Oracle jobs running into each other - oracle

I scheduled three insert procedures at around 3am. The first two were spaced out 10 minutes apart, but the third one was only 5 minutes apart from the second. The third procedure kept failing, and I assumed it might be because the second procedure was still running at the time. All three procedures insert into the same table.
Would the best way to avoid the jobs running into each other be to create a separate procedure that calls the actual inserts in order? Something like this:
CREATE OR REPLACE PROCEDURE DB.DATA_INSERT_ALL IS
BEGIN
EXECUTE DB.DATA_INSERT_1;
EXECUTE DB.DATA_INSERT_2;
EXECUTE DB.DATA_INSERT_3;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
RAISE;
END DATA_INSERT_ALL;
/
What I'm not sure of is: would doing it like this execute each procedure only after the previous is complete (this is what I want)? Or would it try to execute all three at once?
I am doing this on Oracle Express 11g.

Related

Strange oracle job behavior

I face a problem with an oracle job
This job runs every 10 min and it calls a procedure from a package.
Inside the procedure, there is a select and then a loop.
The select could return from 10 to 1000 rows
For one week everything was running fine (, but suddenly it is like the job is not calling the procedure.
It runs successfully every 10 minutes but the procedure is not affecting the rows.
I run the procedure on its own and it works properly.
DBMS Scheduler Run details not showing anything. Everything was successfull. The only difference it that before the problem the run duration was 5 to 30 seconds, and after the problem the duration is just one second.
Do you know what else to look?
Log what's going on within the procedure. How? Create an autonomous transaction procedure which inserts log info into a separate table and commits; as it is an autonomous transaction procedure, that commit won't affect the rest of the transaction (i.e. the main procedure itself).
Log every step of the procedure and then review the result. There's probably something going on, but - it is difficult to guess what. One option might be that you used the
exception
when others then null;
exception handler which successfully hides the problem.

how to call set of procedures in same time without using jobs and chain

I have a package inside package and I have 15 procedures is there but I will run 5 procedures same time,
example: proc1 call---12:22:55
proc2 call---12:22:55
proc3 call---12:22:55
proc4 call---12:22:55
I know that by using chains and jobs it's possible.
Without jobs and chains through front end 1 hit 4 procedures will run at the same time.
I want to start these four procs at the same time.
You can achieve this by using dbms_job
Just create one master procedure which will call all the child procedures parallelly as following:
CREATE OR REPLACE PROCEDURE MASTER_PROC AS
BEGIN
DBMS_JOB.SUBMIT(L_JOB, 'PROC1;');
DBMS_JOB.SUBMIT(L_JOB, 'PROC2;');
DBMS_JOB.SUBMIT(L_JOB, 'PROC3;');
DBMS_JOB.SUBMIT(L_JOB, 'PROC4;');
END MASTER_PROC;
/
Please make sure that job_queue_processes is set to more than four as this parameter decides the maximum number of processes that can be created for the execution of jobs.
Cheers!!

Scheduler Oracle Stored Procedure

I have a simple stored procedure I wanted Oracle to execute weekly and I have put it in the Oracle Scheduler. It was created fine and the scheduled task seems to execute (no error) but my stored procedure does not execute. I have admin right on the database and I do not get any error. Just do not get the result I wanted.
Below is the details of the job:
The creation was successful
The stored procedure is a simple one
create or replace
PROCEDURE DELETEBOGUSLETTERRECORDS AS
BEGIN
DELETE FROM BOGUSLETTERS;
COMMIT;
END DELETEBOGUSLETTERRECORDS;
The procedure was tested outside the scheduler, executed fine and all records in the specified tables were deleted.
However, that same procedure was not executed properly when it was scheduled. I even had the job run immediately, but after it was run, the records were not deleted. No error whatsoever.
What is the issue? Thanks!
I am not sure, but we execute the procedure like this:
[ Type of Job: PL/SQL Block ]
BEGIN
SCHEMA_NAME.STORED_PROC_NAME;
END;
And they run fine like this.

Sequence of procedures and packages followed in a job

I have a scheduled job that runs every day. In that job I have called some stored procedures from various packages. I would like to know is there a sequence that is followed in Oracle i.e the sequence in which I have called them or the stored procedure are executed in any random order.
if you're saying you have a single job (vs one job for each SP) that calls packages like
begin
pkgA.procA;
pkgB.procB;
pkgC.procC;
...
end;
then they are executed in the order you have them in the pl/sql anonymous block.
if you have 1 job for each API call though, then they will either execute in parallel or in any random order.

Oracle PL/SQL: a scheduled procedure, leading to firing of a trigger?

Okay, I'm new to Oracle PL/SQL and I've stumbled across a problem that I cannot figure out.
I have a procedure that leads to transferring data from one table to another and a trigger that activates on the insertion in the second table. I scheduled that procedure to run every minute (for testing - would be daily once I've figured it out), using the DBMS_JOB.SUBMIT - the scheduled part works perfectly, however after the completion of the procedure the trigger is not fired. I tried with before and after insert clauses, but it is still not working. If I call the procedure directly it works and it does fire the trigger just fine. So... I'm already wondering whether the scheduled procedure can fire the trigger at all?!
This is the schedule's code:
DECLARE
VJOBN BINARY_INTEGER;
BEGIN
DBMS_JOB.SUBMIT(
JOB => VJOBN,
INTERVAL => 'SYSDATE + 1/2880',
WHAT => 'BEGIN my_procedure(); END;'
);
END;
create or replace TRIGGER TO_PRJ
AFTER INSERT ON PROJECTS
FOR EACH ROW
BEGIN
IF INSERTING
THEN DBMS_OUTPUT.PUT_LINE('INSERTED PROJECT WITH ID: '||:NEW.PROJECT_ID||')
END IF;
END;​
Table PROJECTS has ID number, name varchar2, and some other that are not important.
The procedure transfers the ID and the name from orders to projects.
P.S. I'm using http://apex.oracle.com and when I get the timestamp from it the time is actually 6 hours behind me - not sure if it can be of any significance...
DBMS_OUTPUT and DBMS_JOB do not work the way you are trying to use them. The scheduled job is probably running, the trigger is firing - but since DBMS_OUTPUTneeds to be activated in the session that executes the DBMS_OUTPUT commands (i.e. the internal session used by DBMS_JOB) you will never see any output.
DBMS_OUTPUT's output is not visible across session, so the session that issues the DBMS_JOB.submit command will NOT receive the output, even if DBMS_OUTPUT is activated for that session.
Try using scheduler, it's much better then jobs. And bring there code of trigger and tables, it may help

Resources