Dear Oracle Masters,
How does one call run_job from inside a trigger?
I can run the following successfully:
exec dbms_scheduler.run_job(job_name => 'MY_USER.MY_JOB');
However, when I put it into a trigger (tried both ways, below), the trigger compiles, but then fails to execute:
create or replace trigger my_user.my_trigger after insert on my_user.my_table
declare
-- v_job varchar2(110) := 'dbms_scheduler.run_job(job_name => ''MY_USER.MY_JOB'')';
begin
EXECUTE IMMEDIATE 'dbms_scheduler.run_job(job_name => ''MY_USER.MY_JOB'')';
-- execute immediate v_job;
end;
/
Trying to insert a record into the table dies with
ORA-00900: invalid SQL statement
ORA-06512: at "MY_USER.MY_TRIGGER", line 6
ORA-04088: error during execution of trigger 'MY_USER.MY_TRIGGER'
What is the correct way of kicking off a job from a trigger (which is what needs doing given the constraints of the current design)?
Thank you!