-- 建立测试表
CREATETABLE t (a NUMBER);
-- 建立存储过程
CREATEORREPLACEPROCEDURE p_parallel (p_min IN NUMBER, p_max IN NUMBER)
IS
BEGIN
INSERTINTO t
SELECT TRUNC (DBMS_RANDOM.VALUE (p_min, p_max)) FROM DUAL;
COMMIT;
END p_parallel;
/
-- 建立job
DECLARE
x NUMBER;
BEGIN
sys.DBMS_JOB.submit (
job => x,
what => 'p_parallel(1,20);p_parallel(21,40);p_parallel(41,60);p_parallel(61,80);',
next_date => TO_DATE ('14-05-2013 00:00:00', 'dd-mm-yyyy hh24:mi:ss'),
interval => 'trunc(sysdate+1)',
no_parse => FALSE);
SYS.DBMS_OUTPUT.put_line ('Job Number is: ' || TO_CHAR (x));
COMMIT;
END;
/
-- 测试
TRUNCATETABLE t;
EXEC dbms_job.run(101);
SELECT * FROM t;
--转自