请问高人如何在ORACLE中根据系统时间设置触发器。
如是SYSDATE是做
星期二,做相应的查询得出一个记录集并往数据库中插入记录。

解决方案 »

  1.   

    利用定时JOB也可以,只要写一个存储过程,设定什么时候执行就可以了。启动定时JOB需要调用包DBMS_JOB中有关功能。
      

  2.   

    SQL*Plus中create table 当前库存表(
            spbm char(6),       --商品编码
            kcsl number         --库存数量
            );create table 历史库存表(
            rq char(8),       --日期
            spbm char(6),       --商品编码
            kcsl number         --库存数量
            );  drop snapshot 计算快照;
    create snapshot 计算快照 refresh next round(sysdate+0.5)+116/144
    as 
    select * from dual;
    --每天晚19:20执行,这个快照什么也不做,只是为了触发下面的触发子,因为在这个快照刷新的时候,有新记录产生
    create or replace trigger 记录历史库存触发子 before insert on snap$_计算快照 for each row
    begin
     insert into 历史库存表(rq,spbm,kcsl)
            select to_char(sysdate,'yyyymmdd'),spbm,kcsl from 当前库存表;
    exception when others then
     raise_application_error(-10000,'不能记录历史库存');
    end;
    /
      

  3.   

    create snapshot 计算快照 refresh next round(sysdate+0.5)+116/144
    as 
    select * from dual;--每天晚19:20执行,这个快照什么也不做,只是为了触发下面的触发子,因为在这个快照刷新的时候,有新记录产生
    如果改系统时间 超过19:20它并未添加记录
    问高人如何解决?