动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库 > Oracle教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Sybase教程,Access教程,DB2教程,数据库安全,数据库文摘
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Oracle教程 ]的信息



本月文章推荐
.ExactPapers Oracle 1Z0-301 200.
.Oracle中SQL*PLUS使用的一些技巧.
.Oracle 9i充分利用自动撤销管理的.
.ExactPapers Oracle 1Z0-026 200.
.Lock_sga = true 的问题.
.教你快速掌握解决RMAN-06026错误.
.LVS的配置详解配置.
.日志恢复数据到时间点(总结).
.使用Oracle 8.0数据库的几点经验.
.Oracle数据库系统性能优化策略.
.Oracle导出备份和导入恢复自动产.
.Linux 上的邮件网关(杀病毒)An.
.使用Text_IO实现EXCEL报表的PLL程.
.Oracle客户端与数据库应用程序集.
.SQL编写规范.
.[Oracle]一次数据库性能问题的tu.
.Oracle SQL性能优化系列讲座之二.
.认识 Linux 档案属性及档案配置.
.系统的物理上不连续的碎片数计算.
.使用未写入文档参数“_ALLOW_RES.

使用dbms_job包来实现数据库后台进程

发表日期:2008-2-9 |



  1建立实现任务的过程
  在schema manager或SQL PLUS里建立如下过程
  CREATE OR REPLACE PROCEDURE "CUSTOMER"."T_JOBTEST" as
  begin
  update emp set active =0
  where active =1
  and date_published < sysdate - active_days;
  end ;
  2 向任务队列中加入任务
  在SQL PLUS中执行下列script
  VARIABLE jobno number;
  begin
   DBMS_JOB.SUBMIT(:jobno, 't_jobtest();', SYSDATE, 'SYSDATE + 1');
   commit;
  end;
  该任务立即执行(SYSDATE),并且每隔一天执行一次('SYSDATE + 1')。
  3 查询此任务是否加入任务队列
  在SQL PLUS中执行下列script
  SELECT job, next_date, next_sec, failures, broken
   FROM user_jobs;
  ------------------
  DBMS_JOB 包介绍
  调度任务队列里的任务要使用DBMS_JOB包中的过程。使用任务队列不需要非凡的数据库特权。任何可以使用这些过程的用户都可以使用任务队列。
  Table 8-2 DBMS_JOB包中的过程
  Procedure Description Described
  SUBMIT
   Submits a job to the job queue. 向任务队列提交一个任务
  REMOVE
   Removes a specified job from the job queue. 从任务队列中删除指定的任务
  CHANGE
   Alters a specified job. You can alter the job description, the time at which the job will be run, or the interval between executions of the job. 改变任务
  WHAT
   Alters the job description for a specified job. 改变指定任务的任务内容
  NEXT_DATE
   Alters the next execution time for a specified job. 改变指定任务的下一次执行时间
  INTERVAL
   Alters the interval between executions for a specified job. 改变指定任务的执行时间间隔。
  BROKEN
   Disables job execution. If a job is marked as broken, Oracle does not attempt to execute it. 禁止指定任务的执行
  RUN
   Forces a specified job to run. 强制执行指定的任务
  Submitting a Job to the Job Queue 向任务队列提交一个任务
  To submit a new job to the job queue, use the SUBMIT procedure in the DBMS_JOB package:
  DBMS_JOB.SUBMIT( job OUT BINARY_INTEGER,
   what IN VARCHAR2,
   next_date IN DATE DEFAULT SYSDATE,
   interval IN VARCHAR2 DEFAULT 'null',
   no_parse IN BOOLEAN DEFAULT FALSE)
  The SUBMIT procedure returns the number of the job you submitted. describes the procedure's parameters.
  Table 8-3 DBMS_JOB.SUBMIT 的参数
  Parameter Description
  job
   This is the identifier assigned to the job you created. You must use the job number whenever you want to alter or remove the job. For more information about job numbers, see "Job Numbers".
  what
   This is the PL/SQL code you want to have executed. 这里是你想执行的PL/SQL代码
  For more information about defining a job, see "Job Definitions".
  next_date
   This is the next date when the job will be run. The default value is SYSDATE.
  interval
   This is the date function that calculates the next time to execute the job. The default value is NULL. INTERVAL must evaluate to a future point in time or NULL.
  For more information on how to specify an execution interval, see "Job Execution Interval".
  no_parse
   This is a flag. The default value is FALSE.
  If NO_PARSE is set to FALSE (the default), Oracle parses the procedure associated with the job. If NO_PARSE is set to TRUE, Oracle parses the procedure associated with the job the first time that the job is executed. If, for example, you want to submit a job before you have created the tables associated with the job, set NO_PARSE to TRUE.
  As an example, let's submit a new job to the job queue. The job calls the procedure DBMS_DDL.ANALYZE_OBJECT to generate optimizer statistics for the table DQUON.ACCOUNTS. The statistics are based on a sample of half the rows of the ACCOUNTS table. The job is run every 24 hours:
  VARIABLE jobno number;
  begin
   2> DBMS_JOB.SUBMIT(:jobno,
   3> 'dbms_ddl.analyze_object(''TABLE'',
   4> ''DQUON'', ''ACCOUNTS'',
   5> ''ESTIMATE'', NULL, 50);'
   6> SYSDATE, 'SYSDATE + 1');
   7> commit;
   8> end;
   9> /
  Statement processed.
  print jobno
  JOBNO
  ----------
  14144
  Job Definition 任务定义任务定义就是SUBMIT过程中WHAT参数中指定的PL/SQL代码。

  通常任务定义(内容)是一个过程的一个调用。这个过程能有任意数量的参数。
  Note: In the job definition, use two single quotation marks around strings. Always include a semicolon at the end of the job definition. 在任务定义中,用2个单引号包围字符串。任务定义的末尾总是带一个分号。
  Jobs and Import/EXPort Jobs can be exported and imported.
   Thus, if you define a job in one database, you can transfer it to another
   database. When exporting and importing jobs, the job's number, environment,
   and definition remain unchanged.
  任务是可以被卸出(exported )卸入(imported)的。
  Job Execution Interval 任务的执行间隔The INTERVAL date function is evaluated immediately before a job is executed. If the job completes sUCcessfully, the date calculated from INTERVAL becomes the new NEXT_DATE. If the INTERVAL date function evaluates to NULL and the job completes successfully, the job is
   deleted from the queue. If a job should be executed periodically at a set interval, use a date expression similar to 'SYSDATE + 7' in the INTERVAL
   parameter. For example, if you set the execution interval to 'SYSDATE + 7' on Monday, but for some reason (such as a network failure) the job is not
   executed until Thursday, 'SYSDATE + 7' then executes every Thursday, not Monday.
  If you always want to automatically execute a job at a specific time, regardless of the last execution (for example, every Monday), the INTERVAL and NEXT_DATE parameters should specify a date expression similar to 'NEXT_DAY(TRUNC(SYSDATE), "MONDAY")'.
  Table 8-5 lists some common date expressions used for job execution intervals.
  Table 8-5 Common Job Execution Intervals Date Expression Evaluation 'SYSDATE + 7'
   exactly seven days from the last execution 最后一次执行的7天之后执行 'SYSDATE + 1/48'
   every half hour 每半个小时执行一次 'NEXT_DAY(TRUNC(SYSDATE),
  ''MONDAY'') + 15/24'
   every Monday at 3PM 每个礼拜一的下午3点执行 'NEXT_DAY(ADD_MONTHS(TRUNC(SYSDATE, ''Q''), 3),
  ''THURSDAY'')'
   first Thursday of each quarter 每个季度的第一个星期四 --------------------------------------------------------------------------------Note: When specifying NEXT_DATE or INTERVAL, remember that date literals and strings must be enclosed in single quotation marks. Also, the value of INTERVAL must be enclosed in single quotation marks. --------------------------------------------------------------------------------
  Removing a Job from the Job Queue 删除任务队列中的任务
  To remove a job from the job queue, use the REMOVE procedure in the DBMS_JOB package:
  DBMS_JOB.REMOVE(job IN BINARY_INTEGER)
  The following statement removes job number 14144 from the job queue:
  DBMS_JOB.REMOVE(14144);
  Syntax for WHAT
  You can alter the definition of a job by calling the DBMS_JOB.WHAT procedure. Table 8-3 describes the procedure's parameters.
  DBMS_JOB.WHAT( job IN BINARY_INTEGER,

   what IN VARCHAR2)
  --------------------------------------------------------------------------------
  Note:
  When you execute procedure WHAT, Oracle records your current environment. This becomes
上一篇:Oracle协作套件:完全集成数据库 人气:370
下一篇:Oracle 9i新特性研究系列之七 人气:377
浏览全部Oracle教程的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-24 Sablog-X v2.0 预览版
2008-7-24 帝国备份王EmpireBak 2008 正式版
2008-7-24 网趣网上购物系统时尚版 v8.2
2008-7-24 纵横B2B电子商务系统XYECS!B2B v
2008-7-24 e路小说小偷 v1.2.0723
2008-7-24 凌风美女图片站程序 v2.2
2008-7-24 TOM15电影收索程序
2008-7-24 清风信息自动采集生成系统 v1.0
2008-7-24 QQ邮箱编辑器 v1.0 (小小菜刀ASP
2008-7-19 UltraEdit 简体中文增强版 14.10
2008-7-19 CentOS 5.2 i386 LiveCD
2008-7-19 Snapture多功能相机 v1.4
2008-7-19 iAcces中文输入法 v1.0Build016
2008-7-19 Cookbook烹饪秘籍 v2.5
2008-7-19 苹果专用DVD转换工具 v1.1.59汉化
2008-7-19 Modem修复软件ZiPhone修改版04.0
2008-7-19 AgileMessenger即时通讯工具美化
2008-7-19 Sketches画图软件 v0.7b6破解版


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵