oracle job的使用


select job, next_date, next_sec, failures, broken from user_jobs;

create or replace sequence END_REST_SEQ
minvalue 0
maxvalue 9999999999
start with 1
increment by 1
cache 10;

select END_REST_SEQ.nextval from dual


create or replace procedure REST_SEQU_PROCEDURE Authid Current_User as
n number(10);
tsql varchar2(100);
begin
execute immediate 'select END_REST_SEQ.nextval from dual' into n;
n:=-n;
tsql:='alter sequence END_REST_SEQ increment by '|| n;
execute immediate tsql;
execute immediate 'select END_REST_SEQ.nextval from dual' into n;
tsql:='alter sequence END_REST_SEQ increment by 1';
execute immediate tsql;
end;

CALL REST_SEQU_PROCEDURE();

declare
job number;
begin
dbms_job.submit(job,'REST_SEQU_PROCEDURE;', sysdate, 'sysdate+1/(24*60)');
commit;
end;


create or replace procedure REST_SEQU_PROCEDURE as
n_count number(8);
begin
select count(1)
into n_count
from user_sequences t
where t.sequence_name = 'END_REST_SEQ';

if n_count > 0 then
execute immediate 'drop sequence END_REST_SEQ';
end if;

execute immediate 'create sequence END_REST_SEQ
minvalue 0
maxvalue 99999999
start with 1
increment by 1;
commit;
end;

select * from v$diag_info

declare
begin
dbms_job.remove(15);
commit;
end;

begin
dbms_job.run(14);
end;

posted @ 2021-10-21 14:07  hsyooy  阅读(31)  评论(0编辑  收藏  举报