添加表、字段、存储过程、定时任务

-- Create table
create table UPDATE_MSG_CONTENT_LOG
(
  detail     VARCHAR2(300),
  content    VARCHAR2(1536),
  subject    VARCHAR2(300),
  pk_message CHAR(20) not null,
  backupts   DATE,
  ts         CHAR(19),
  receiver   CHAR(20)
)
tablespace NNC_DATA01
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    next 8K
    minextents 1
    maxextents unlimited
  );


-- Alter table 

alter table UPDATE_MSG_CONTENT_LOG
  storage
  (
    next 1
  )
;
-- Add/modify columns 

alter table UPDATE_MSG_CONTENT_LOG add receiver CHAR(20);


create or replace procedure Update_Msg_Content
IS
      ---游标
      CURSOR TEMP_CUR IS
      
select DETAIL,CONTENT,SUBJECT,RECEIVER,PK_MESSAGE,SYSDATE BACKUPTS,TS
  from sm_msg_content
 where DETAIL not in
       ((select pk_leaveh || '@6404@' || bill_code from tbm_leaveh) UNION ALL(select pk_overtimeh||'@6405@'||bill_code from tbm_overtimeh))
   and (DETAIL like '%@6404@%' OR DETAIL like '%@6405@%')
   and msgtype <> 'email'
   and msgsourcetype ='notice'
   and isdelete = 'N'
   and ishandled = 'N'
   and isread = 'N';


begin
        For TEMP_CUR_RECORD in TEMP_CUR loop---遍历游标


        IF TEMP_CUR_RECORD.RECEIVER IS NOT NULL  THEN
          INSERT INTO Update_Msg_Content_LOG(Detail, Content, Subject, Receiver, Pk_Message, Backupts, Ts) VALUES (TEMP_CUR_RECORD.DETAIL,TEMP_CUR_RECORD.CONTENT,TEMP_CUR_RECORD.SUBJECT,TEMP_CUR_RECORD.RECEIVER,TEMP_CUR_RECORD.PK_MESSAGE,TEMP_CUR_RECORD.BACKUPTS,TEMP_CUR_RECORD.TS);
          UPDATE sm_msg_content SET sm_msg_content.isdelete = 'Y' WHERE sm_msg_content.Pk_Message=TEMP_CUR_RECORD.PK_MESSAGE;


        ELSE 
          INSERT INTO Update_Msg_Content_LOG(Detail, Content, Subject, Receiver, Pk_Message, Backupts, Ts) VALUES (TEMP_CUR_RECORD.DETAIL,TEMP_CUR_RECORD.CONTENT,TEMP_CUR_RECORD.SUBJECT,TEMP_CUR_RECORD.RECEIVER,TEMP_CUR_RECORD.PK_MESSAGE,TEMP_CUR_RECORD.BACKUPTS,TEMP_CUR_RECORD.TS);
          UPDATE sm_msg_content SET sm_msg_content.isread = 'Y' WHERE sm_msg_content.Pk_Message=TEMP_CUR_RECORD.PK_MESSAGE;
        
        END IF;


  end loop;
  
  commit;

  
end;


    Declare
      i Integer;
    Begin
       dbms_job.submit(i,'Update_Msg_Content;',Sysdate,'TRUNC(sysdate+1)+2/24');
    end;

/*begin
  sys.dbms_job.change(job => 21,
                      what => 'Update_Msg_Content;',
                      next_date => to_date('23-11-2017 16:12:17', 'dd-mm-yyyy hh24:mi:ss'),
                      interval => 'TRUNC(sysdate+1)+17/24');
  commit;
end;
/    */


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值