在Oracle PlSql中,我在屏幕上执行某些操作后调用我的存储过程。 在执行了一些代码之后,我想在表中插入一些记录,但插入应该在20分钟后发生。我想独立地运行插入作业/过程,以便我的主程序完成它的执行。
任何形式的帮助都将受到赞赏!!
答案 0 :(得分:1)
希望下面的代码段有用。
--Table to create dummy insertion
CREATE TABLE TEST_SO_TAB
(
COL1 NUMBER
);
--Procedure to replicate scenario
CREATE OR REPLACE
PROCEDURE TEST_SO_SCHEDULER(
p_in IN NUMBER)
AS
lv sys.odcinumberlist;
BEGIN
SELECT LEVEL BULK COLLECT INTO lv FROM dual CONNECT BY level < 100;
DBMS_SCHEDULER.create_job ( job_name => 'DELTA_REFRESH_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'DECLARE
lv1 sys.odcinumberlist;
BEGIN
SELECT LEVEL BULK COLLECT INTO lv1 FROM dual CONNECT BY level < 100;
IF lv1.EXISTS(1) THEN
FORALL i IN lv1.FIRST..lv1.LAST
INSERT INTO TEST_SO_TAB VALUES
( lv1(i)
);
END IF;
END',
start_date => SYSTIMESTAMP+ INTERVAL '20' MINUTE,
end_date => NULL,
enabled => TRUE,
comments => 'Job defined entirely by the CREATE JOB procedure.');
END;
/