用户登录HAMS档案管理系统,自动提示用户借阅的那些档案过期未还,操作步骤如下:
1、确定需要提醒的档案数字所在的数据库表 ,例如D_FILE1
2、根据实际情况修改如下存储过程:
作用:自动根据用户实际情况将过期信息放入提醒库//借阅提醒代码
CREATE OR REPLACE PROCEDURE "DUETOREMIND" AS
v_ename varchar2(200);
usercodevar varchar2(200);
llcount number;
ll_duenum number;
lldid number;
v_duenumname varchar2(200);
BEGIN
declare CURSOR mycur is
SELECT OPERATOR ,count(*) as "llnum"
FROM S_BORROW
WHERE YJGHSJ <= sysdate and (YJGHSJ is not null) group by OPERATOR;
begin
open mycur();
fetch mycur into v_ename,ll_duenum;
while (mycur%found)
loop
select count(*) into llcount from S_USER WHERE USERNAME=v_ename;
if (llcount >0) then
select USERCODE INTO usercodevar from S_USER WHERE USERNAME=v_ename ;
else
usercodevar:=v_ename;
end if;
lldid:=1;
select max(did) into lldid from s_backlog;
if ( lldid is null) then
lldid:=1;
else
lldid:=lldid +1;
end if ;
insert into S_BACKLOG(DID,URGENCY,PTABLE,OPERMODULEZH,OPERTYPE,OPERDATE,USERCODE,ISOPER,TITLE,OPERMODULEOWNER)values(
lldid,0,'S_BORROW','归还管理',3,sysdate,usercodevar,0,'您有'|| ll_duenum || '个档案已经过期,请单击进入该模块进行处理!','lyh');
commit;
fetch mycur into v_ename, ll_duenum;
end loop;
close mycur;
end;
end;
3、把存储过程加入数据库的定时执行,执行如下代码:
variable job1 number;
begin
dbms_job.submit(:job1,'testproc;',sysdate,'sysdate+1/1440');
end;
begin
dbms_job.run(:job1);
end;
dbms_job.remove(:job1);
dbms_job.submit(:test_job,'DUETOREMIND;',sysdate,'sysdate+1’);第四个参数说明:sysdate+1 表示每天执行一次 sysdate+1/24 表示每小时执行一次 sysdate+1/(24*60) 表示每分钟执行一次 sysdate+1/(24*60*60) 表示每秒执行一次3
4、通常情况下执行完第三步即可,当然,如果有问题,请往下看:
“并非所有变量都已关联”的解决办法SQL> begin2 dbms_job.interval(:job_clearexpiredata, 'sysdata+1');3 end;4 /begin dbms_job.interval(:job_clearexpiredata, 'sysdata+1');end;