job还是job
declare
jobno binary_integer;
rm_days number;
rm_hour number; --传入的hour
my_hour number; --取出当前时间的hour
my_interval_day number;
my_interval varchar2(20);
my_sql varchar2(200);
my_next_date varchar2(200);
my_yymmdd varchar2(200);
my_own_sql varchar2(2000);
begin
rm_days:=30;
rm_hour:=11;
my_interval_day:=1;
my_sql:='''delete from log_info_bak where currenttime <sysdate-'||rm_days||';''';
dbms_output.put_line('my_sql is: '||my_sql);
--判断两个hour
select to_number(to_char(sysdate,'hh24')) into my_hour from dual;
-- dbms_output.put_line(my_hour);
--16 18
if rm_hour < my_hour then
rm_hour:=rm_hour;
select to_char(sysdate+1,'yyyy-mm-dd') into my_yymmdd from dual;
my_next_date:='to_date('''||my_yymmdd ||' '||rm_hour||':00:00'' ,''yyyy-mm-dd hh24:mi:ss'')';
--20 18
elsif rm_hour>my_hour then
select to_char(sysdate,'yyyy-mm-dd') into my_yymmdd from dual;
my_next_date:='to_date('''||my_yymmdd ||' '||rm_hour||':00:00'' ,''yyyy-mm-dd hh24:mi:ss'')';
-- dbms_output.put_line(rm_hour);
end if;
dbms_output.put_line('my_next_date is:'||my_next_date);
my_interval:='''sysdate+'||to_char(my_interval_day)||'''';
--my_interval:='sysdate+1';
dbms_output.put_line('my_interval is: '||my_interval);
my_own_sql:=' declare jobno binary_integer; begin dbms_job.submit(job => jobno,what => '||my_sql||',next_date => '||my_next_date||',interval =>'||my_interval||'); commit; end;';
dbms_output.put_line(my_own_sql);
execute immediate my_own_sql;
/* dbms_job.submit(job => jobno,
what => my_sql,
next_date => my_next_date,
interval => my_interval);*/
commit;
end;
--测试部分
/*
系统 time 11:00:00 任务时间 9点 结果 执行时间推迟到 to_date('2016-12-21 9:00:00' ,'yyyy-mm-dd hh24:mi:ss')
系统 time 9:00:00 任务时间 11点 结果 执行时间推迟到 to_date('2016-12-20 11:00:00' ,'yyyy-mm-dd hh24:mi:ss')
*/
随机推荐
- 多控制器之UIApplication
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- Java笔记(四)……常量与变量
常量 常量表示不会改变的数值. Java中常量的分类: 整数常量:所有整数 小数常量:所有小数 布尔型常量:较为特有,只有两个数值,true false 字符常量:将一个数字字母或者符号用单引号(' ...
- POJ3349: Snowflake Snow Snowflakes(hash 表)
考察hash表: 每一个雪花都有各自的6个arm值,如果两个雪花从相同或者不同位置开始顺时针数或者逆时针数可以匹配上,那么这两个雪花就是相等的. 我们采用hash的方法,这样每次查询用时为O(1),总 ...
- Add And Reset a Federation Server to a Federation Server Farm adfs ad
Applies To: Active Directory Federation Services (AD FS) 2.0 After you install the Active Directory ...
- 安装、配置JDK的步骤
1.配置环境变量,打开我的电脑--属性--高级--环境变量,新建系统变量JAVA_HOME .变量值:jdk的目录,比如d:/java.选择“系统变量”中变量名为“Path”的环境变量双击该变量,把J ...
- 【LeetCode】Agorithms 题集(一)
Single Number 题目 Given an array of integers, every element appears twice except for one. Find that s ...
- [React Native] Passing data when changing routes
The way you make HTTP requests in React Native is with the Fetch API. In this video we'll talk about ...
- 使用ThinkPHP框架高速开发站点(多图)
使用ThinkPHP框架高速搭建站点 这一周一直忙于做实验室的站点,基本功能算是完毕了.比較有收获的是大概了解了ThinkPHP框架.写一些东西留作纪念吧.假设对于相同是Web方面新手的你有一丝丝帮助 ...
- phpmailer,smtp发送邮件实例(转)
一,用phpmailer发送邮件 查看复制打印? <?php include "class.phpmailer.php"; //包函邮件发送类 //邮件发 ...
- 问题分析探讨 --> 大约有700W数据的表,把当天的10W数据select导入新表,整个原来的表就锁死
Sun shine 16:15:55 帅哥 我有个手机表 大约有700百数据,,每天新增 大约五万,并且新也有update 大约10万 然后 我每晚 把当天的数据select 导入一个新表中的时 ...