定时任务可以很好的帮助我们执行一些重复性的工作,比如每天一次或者每周一次的定时表检查,我们根据目的来定义一个JOB去执行我们需要的存储。
那么首先,我们就需要先定义一个需要执行的存储,在JOB中指的就是WAHT()。
创建存储:
create or replace procedure p_ex_cur as
null_excep exception;--自定义一个异常
class_new1 class_new2%rowtype;--定义一个和class_new的字段类型和名称一样的变量
cursor cur_ex is select * from class_new2;--定义一个显性游标
begin
for class_new1 in cur_ex loop --FOR语句循环遍历游标中的数据
begin -- 开始begin,end嵌套
if class_new1.class_id is null then --进行if判断
raise null_excep; -- 抛出异常
end if;
exception
when null_excep then -- 异常抛出之后的操作
insert into class_new2 (class_te,class_date)values('class_id为空',sysdate);
commit;
end;