美文网首页
SQL简单使用

SQL简单使用

作者: louiema1n | 来源:发表于2018-08-02 10:22 被阅读0次

    创建存储过程

    create or replace procedure 过程名 is
      cursor locked_orders is
        select t.* from 表名 t where t.LOCK_STATE = '0' and t.LOCK_TIME < sysdate-24/24;
    begin
      for locked_order in locked_orders loop
        begin
          update 表名 t
          set
            t.LOCK_STATE = '1'
          where t.LOCK_ID = locked_order.LOCK_ID;
        end;
      end loop;
      commit;
    end 过程名;
    

    创建定时任务

    以下命令是在PLSQL是命令窗口中执行

    variable job1 number;
    begin
      sys.dbms_job.submit(job => :job1,
                          what => '存储过程名;',
                          next_date => sysdate,
                          interval => 'SYSDATE+1/24');
      commit;
      sys.dbms_job.run(:job1);
    end;
    /
    

    相关文章

      网友评论

          本文标题:SQL简单使用

          本文链接:https://www.haomeiwen.com/subject/zbljvftx.html