Oracle处理数据比对自动推送方案

Oracle处理数据比对自动推送方案


以下场景只作为演练演示整个流程,个人依据自己的实际情况来做。

演练服务器情况:

服务器清单:

11.71.253.66

10.74.132.107

10.74.132.85

11.71.253.126


一、每日8:20在11.71.253.66服务器上,通过Kettle数据迁移工具,把海康TIM的PostgreSQL数据库中的信息推送到11.71.253.66服务器上的Oracle数据库。

其中表table包括:crossing、lane、region、tim_wf、vvt_cross_lane。


二、每日9:00在10.74.132.107服务器上,通过Oracle Job任务(handle_config)从11.71.253.66服务器中抽取数据。

详细的执行步骤

2.1、先把表数据备份到bak表中。

2.2、从11.71.253.66服务器插入表数据。包括:crossing、lane、region、tim_wf、vvt_cross_lane。

2.3、查看bak表中的信息。

每日查看是不是最新日期,查看SQL:

select to_char(cjrq,'yyyy-mm-dd hh24:mi:ss') cjrqstr,t.* from CROSSING_BAK t order by cjrq desc;
select to_char(cjrq,'yyyy-mm-dd hh24:mi:ss') cjrqstr,t.* from LANE_BAK t order by cjrq desc;
select to_char(cjrq,'yyyy-mm-dd hh24:mi:ss') cjrqstr,t.* from REGION_BAK t order by cjrq desc;
select to_char(cjrq,'yyyy-mm-dd hh24:mi:ss') cjrqstr,t.* from TIM_WF_BAK t order by cjrq desc;
select to_char(cjrq,'yyyy-mm-dd hh24:mi:ss') cjrqstr,t.* from VVT_CROSS_LANE_BAK t order by cjrq desc;

三、每日9:00在10.74.132.107服务器上,通过Oracle Job任务(do_your_job_123)从10.74.132.85服务器中抽取集成每日违法数据。

涉及表:RM_WF
每日查看是不是最新日期,执行下面SQL查看:

select to_char(cjrq,'yyyy-mm-dd hh24:mi:ss') cjrqstr,t.* from TIM_WF_BAK t order by cjrq desc;

四、每日9:30在10.74.132.107服务器上,通过Oracle Job任务(rm_report),生成报表。

涉及的表:

select * from wf_report_deffer;
select * from wf_report_deffer_1dd;
select * from wf_report_deffer_2dd;
select * from wf_report_deffer_3dd;
select * from wf_report_detail;
select * from wf_report_detail_1dd;
select * from wf_report_detail_2dd;
select * from wf_report_detail_3dd;

五、每日10:00在10.74.132.107服务器上,通过Oracle Job任务(send_data_to_66),把上述报表推送到11.71.253.66。

PL/SQL登录11.71.253.66服务器查看表是不是最新日期,日期应该是9:30,执行下面SQL查询:

select * from wf_report_deffer;
select * from wf_report_deffer_1dd;
select * from wf_report_deffer_2dd;
select * from wf_report_deffer_3dd;
select * from wf_report_detail;
select * from wf_report_detail_1dd;
select * from wf_report_detail_2dd;
select * from wf_report_detail_3dd;

六、每日10:30在11.71.253.66服务器上,通过Oracle Job任务(send_data_to_126),把上述报表数据推送到11.71.253.126服务器。

----远程到11.71.253.66服务器,登录11.71.253.126服务器(Jzjgzhxt01)查看表是不是最新日期,日期应该是9:30,执行下面SQL查询:

select * from wf_report_deffer;
select * from wf_report_deffer_1dd;
select * from wf_report_deffer_2dd;
select * from wf_report_deffer_3dd;
select * from wf_report_detail;
select * from wf_report_detail_1dd;
select * from wf_report_detail_2dd;
select * from wf_report_detail_3dd;

七、每日11:00在11.71.253.126服务器上,通过8个Windows计划任务,自动生成HTML文件。

远程到11.71.253.126服务器,查看目录 E:\tzq\wf\report 下是否生成HTML文件。


八、每日11:30在11.71.253.126服务器上,通过Oracle Job任务(sent_wf_to_mail_go),把HTML文件发送邮件到各个大队接收人。

8.1、邮件发送人名单

杨远:[email protected]
阮善强:[email protected]
李凌:[email protected]
尹松柏:[email protected]
樊浩:[email protected]
一大队叶伦:  [email protected]
二大队宋宁静:[email protected]
二大队韩艳:[email protected]
三大队张智洋:[email protected]

8.2、邮件正文优化提示。

8.2.1、目前只能单人发送邮件

8.2.1.1、目前总表发送邮件清单

sent_wf_to_mail_zl('总表','[email protected]');
sent_wf_to_mail_zl('总表','[email protected]');
sent_wf_to_mail_zl('总表','[email protected]');
sent_wf_to_mail_zl('总表','[email protected]');
sent_wf_to_mail_zl('总表','[email protected]');
sent_wf_to_mail_zl('总表','[email protected]');
sent_wf_to_mail_zl('总表','[email protected]');

8.2.1.2、一大队发送邮件清单

sent_wf_to_mail_1dd('一大队','[email protected]');
sent_wf_to_mail_1dd('一大队','[email protected]');
sent_wf_to_mail_1dd('一大队','[email protected]');

8.2.1.3、二大队发送邮件清单

sent_wf_to_mail_2dd('二大队','[email protected]');
sent_wf_to_mail_2dd('二大队','[email protected]');
sent_wf_to_mail_2dd('二大队','[email protected]');
sent_wf_to_mail_2dd('二大队','[email protected]');

8.2.1.4、三大队发送邮件清单

sent_wf_to_mail_3dd('三大队','[email protected]');
sent_wf_to_mail_3dd('三大队','[email protected]');
sent_wf_to_mail_3dd('三大队','[email protected]');

九、创建各存过

9.1、创建存过 P_SEND_MAIL()

创建存过 P_SEND_MAIL() 这个存过的脚本,可以看我另外一篇博文:
Oracle发送邮件 --> 一、创建发送邮件存过

9.2、创建存过 sent_wf_to_mail_zl()

CREATE OR REPLACE PROCEDURE sent_wf_to_mail_zl
(--文件名称含本地目录,2个附件发送,按大队发
v_dd in varchar2,    --大队:总量
v_mail in varchar2   --邮件接收人
)
AUTHID CURRENT_USER is
  v_today VARCHAR2(50);      --今天的日期文本
  v_yesterday VARCHAR2(50);  --昨天的日期文本
  v_file_all_name  VARCHAR2(1000);--文件汇总
  v_file_all_name1 VARCHAR2(500); --文件1全名称
  v_file_all_name2 VARCHAR2(500); --文件2全名称
  v_title          VARCHAR2(500);  --邮件标题
  v_content          VARCHAR2(4000);  --邮件正文
  v_hk_zl            VARCHAR2(50);    --海康总量
  v_fail_sl          VARCHAR2(50);    --海康上传失败
  v_sl               VARCHAR2(50);    --海康上传成功
  v_jc_zl            VARCHAR2(50);    --集成接收总量
  v_wf_ylr            VARCHAR2(50);   --集成已录入量
  v_wf_dsx            VARCHAR2(50);   --集成待核对量
  v_wf_cw            VARCHAR2(50);    --集成无效数量
  v_cys              VARCHAR2(50);    --集成海康违法数量差异数
begin
  select to_char(sysdate,'yyyymmdd') into v_today from dual;
  select to_char(sysdate-1,'yyyy-mm-dd') into v_yesterday from dual;
  select sum(hk_zl) into v_hk_zl from WF_REPORT_DEFFER;
  select sum(fail_sl) into v_fail_sl from WF_REPORT_DEFFER;
  select sum(sl) into v_sl from WF_REPORT_DEFFER;
  select sum(jc_zl) into v_jc_zl from WF_REPORT_DEFFER;
  select sum(wf_ylr) into v_wf_ylr from WF_REPORT_DEFFER;
  select sum(wf_dsx) into v_wf_dsx from WF_REPORT_DEFFER;
  select sum(wf_cw) into v_wf_cw from WF_REPORT_DEFFER;
  select sum(hk_zl)-sum(jc_zl) into v_cys from WF_REPORT_DEFFER;
  v_file_all_name1:='E:\tzq\wf\report\'||v_today||'-集成海康违法数据比对差异表(根据昨日数据)-'||v_dd||'.html';
  v_file_all_name2:='E:\tzq\wf\report\'||v_today||'-集成海康违法数据比对详情表(根据昨日数据)-'||v_dd||'.html';
  v_file_all_name:=v_file_all_name1||','||v_file_all_name2;
  v_title:='【荆州市公安交通管理局】-集成海康违法数据比对分析报告('||v_yesterday||'的数据)-'||v_dd;--邮件标题
  --邮件正文
  v_content:=v_title
  ||utl_tcp.CRLF||v_yesterday||'交管局违法数据统计如下:'
  ||utl_tcp.CRLF||'一、海康TIM平台违法量。'
  ||utl_tcp.CRLF||'  1.1、海康总量:'||v_hk_zl
  ||utl_tcp.CRLF||'  1.2、上传成功:'||v_sl
  ||utl_tcp.CRLF||'  1.3、上传失败:'||v_fail_sl
  ||utl_tcp.CRLF||'二、集成平台违法量。'
  ||utl_tcp.CRLF||'  2.1、接收总量:'||v_jc_zl
  ||utl_tcp.CRLF||'  2.2、已录入量:'||v_wf_ylr
  ||utl_tcp.CRLF||'  2.3、待核对量:'||v_wf_dsx
  ||utl_tcp.CRLF||'  2.4、无效数量:'||v_wf_cw
  ||utl_tcp.CRLF||'三、集成海康违法比对差异数。'
  ||utl_tcp.CRLF||'  差异总数为(海康总量减集成总量):'||v_cys
  ||utl_tcp.CRLF
  ||utl_tcp.CRLF||'(详情请看附件内容)'
  ;
  --dbms_output.put_line('v_file_all_name:'||v_file_all_name);
  --dbms_output.put_line('v_content:'|| v_content);
  P_SEND_MAIL(v_content,--邮件正文
              v_title,--邮件标题
              '[email protected]',--发送邮箱
              v_mail,--接收邮箱
              'smtp.163.com',
              25,
              1,
              '[email protected]',--发送邮箱的账号
              'xxxxxxx',--发送邮箱的密码
              v_file_all_name, --文件
              'base64');
end;

9.3、创建存过 job_to_zl()

CREATE OR REPLACE PROCEDURE job_to_zl AUTHID CURRENT_USER IS
BEGIN
  sent_wf_to_mail_zl('总表','[email protected]');
  sent_wf_to_mail_zl('总表','[email protected]');
  sent_wf_to_mail_zl('总表','[email protected]');
  sent_wf_to_mail_zl('总表','[email protected]');
  sent_wf_to_mail_zl('总表','[email protected]');
  sent_wf_to_mail_zl('总表','[email protected]');
  sent_wf_to_mail_zl('总表','[email protected]');
END;

9.4、创建存过 sent_wf_to_mail_1dd()

CREATE OR REPLACE PROCEDURE sent_wf_to_mail_1dd
(--文件名称含本地目录,2个附件发送,按大队发
v_dd in varchar2,    --大队:总量
v_mail in varchar2   --邮件接收人
)
AUTHID CURRENT_USER is
  v_today VARCHAR2(50);      --今天的日期文本
  v_yesterday VARCHAR2(50);  --昨天的日期文本
  v_file_all_name  VARCHAR2(1000);--文件汇总
  v_file_all_name1 VARCHAR2(500); --文件1全名称
  v_file_all_name2 VARCHAR2(500); --文件2全名称
  v_title          VARCHAR2(500);  --邮件标题
  v_content          VARCHAR2(4000);  --邮件正文
  v_hk_zl            VARCHAR2(50);    --海康总量
  v_fail_sl          VARCHAR2(50);    --海康上传失败
  v_sl               VARCHAR2(50);    --海康上传成功
  v_jc_zl            VARCHAR2(50);    --集成接收总量
  v_wf_ylr            VARCHAR2(50);   --集成已录入量
  v_wf_dsx            VARCHAR2(50);   --集成待核对量
  v_wf_cw            VARCHAR2(50);    --集成无效数量
  v_cys              VARCHAR2(50);    --集成海康违法数量差异数
begin
  select to_char(sysdate,'yyyymmdd') into v_today from dual;
  select to_char(sysdate-1,'yyyy-mm-dd') into v_yesterday from dual;
  select sum(hk_zl) into v_hk_zl from WF_REPORT_DEFFER_1DD;
  select sum(fail_sl) into v_fail_sl from WF_REPORT_DEFFER_1DD;
  select sum(sl) into v_sl from WF_REPORT_DEFFER_1DD;
  select sum(jc_zl) into v_jc_zl from WF_REPORT_DEFFER_1DD;
  select sum(wf_ylr) into v_wf_ylr from WF_REPORT_DEFFER_1DD;
  select sum(wf_dsx) into v_wf_dsx from WF_REPORT_DEFFER_1DD;
  select sum(wf_cw) into v_wf_cw from WF_REPORT_DEFFER_1DD;
  select sum(hk_zl)-sum(jc_zl) into v_cys from WF_REPORT_DEFFER_1DD;
  v_file_all_name1:='E:\tzq\wf\report\'||v_today||'-集成海康违法数据比对差异表(根据昨日数据)-'||v_dd||'.html';
  v_file_all_name2:='E:\tzq\wf\report\'||v_today||'-集成海康违法数据比对详情表(根据昨日数据)-'||v_dd||'.html';
  v_file_all_name:=v_file_all_name1||','||v_file_all_name2;
  v_title:='【荆州市公安交通管理局】-集成海康违法数据比对分析报告('||v_yesterday||'的数据)-'||v_dd;--邮件标题
  --邮件正文
  v_content:=v_title
  ||utl_tcp.CRLF||v_yesterday||'交管局违法数据统计如下:'
  ||utl_tcp.CRLF||'一、海康TIM平台违法量。'
  ||utl_tcp.CRLF||'  1.1、海康总量:'||v_hk_zl
  ||utl_tcp.CRLF||'  1.2、上传成功:'||v_sl
  ||utl_tcp.CRLF||'  1.3、上传失败:'||v_fail_sl
  ||utl_tcp.CRLF||'二、集成平台违法量。'
  ||utl_tcp.CRLF||'  2.1、接收总量:'||v_jc_zl
  ||utl_tcp.CRLF||'  2.2、已录入量:'||v_wf_ylr
  ||utl_tcp.CRLF||'  2.3、待核对量:'||v_wf_dsx
  ||utl_tcp.CRLF||'  2.4、无效数量:'||v_wf_cw
  ||utl_tcp.CRLF||'三、集成海康违法比对差异数。'
  ||utl_tcp.CRLF||'  差异总数为(海康总量减集成总量):'||v_cys
  ||utl_tcp.CRLF
  ||utl_tcp.CRLF||'(详情请看附件内容)'
  ;
  --dbms_output.put_line('v_file_all_name:'||v_file_all_name);
  --dbms_output.put_line('v_content:'|| v_content);
  P_SEND_MAIL(v_content,--邮件正文
              v_title,--邮件标题
              '[email protected]',--发送邮箱
              v_mail,--接收邮箱
              'smtp.163.com',
              25,
              1,
              '[email protected]',--发送邮箱的账号
              'xxxxxxx',--发送邮箱的密码
              v_file_all_name, --文件
              'base64');
end;

9.5、创建存过 job_to_1dd()

CREATE OR REPLACE PROCEDURE job_to_1dd
AUTHID CURRENT_USER is
begin
	sent_wf_to_mail_1dd('一大队','[email protected]');
	sent_wf_to_mail_1dd('一大队','[email protected]');
	sent_wf_to_mail_1dd('一大队','[email protected]');
end;

十、错误处理

10.1、ORA-24247: 网络访问被访问控制列表 (ACL) 拒绝

解决方法:控制列表处理

10.1.1、使用 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL 创建访问控制列表(ACL)

执行下面的SQL:

BEGIN
  dbms_network_acl_admin.create_acl(acl => 'email_server_permissions.xml'
                                   ,description => 'Enables network permissions for the e-mail server'
                                   -- Oracle运行存储过程的用户
                                   ,principal => 'TZQ2018'
                                   ,is_grant => TRUE
                                   ,privilege => 'connect');
  COMMIT;
END;
/

10.1.2、使用 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL 将此 ACL 与邮件服务器相关联

这里是绑定了163邮箱用来给客户发送邮件。
执行下面的SQL:

BEGIN
  dbms_network_acl_admin.assign_acl(acl => 'email_server_permissions.xml'
                                   ,host => 'smtp.163.com'
                                   , ---SMTP服务器地址
                                    lower_port => 25
                                   , --端口
                                    upper_port => NULL);
  COMMIT;
END;
/

10.2、邮件发送失败! ORA-01031: 权限不足

错误信息日志如下:

----- PL/SQL Call Stack -----
  object      line  object
  handle    number  name
000000028CF1E838       351  procedure TZQ.P_SEND_MAIL
00000002ADC4A128        61  procedure TZQ.SENT_WF_TO_MAIL_1DD
00000002AA982C10         6  procedure TZQ.JOB_TO_1DD
00000002ADC80718         1  anonymous block
00000002AC15BE80       648  package body SYS.DBMS_IJOB
00000002ADBD9F88       284  package body SYS.DBMS_JOB
000000028CDEECC8         2  anonymous block

解决方法:用户授权

10.2.1、用户授权

执行下面的授权SQL:

grant execute on SYS.JOB to TZQ;
grant execute on SYS.UTL_SMTP to TZQ;
grant execute on SYS.UTL_TCP to TZQ;
grant connect to TZQ;
grant dba to TZQ;
grant resource to TZQ;

grant administer any sql tuning set to TZQ;
grant administer database trigger to TZQ;
begin
  dbms_resource_manager_privs.grant_system_privilege(
    grantee_name   => 'TZQ',
    privilege_name => 'administer_resource_manager',
    admin_option   => false);
end;
/
grant administer sql management object to TZQ;
grant administer sql tuning set to TZQ;
grant advisor to TZQ;
grant alter any assembly to TZQ;
grant alter any cluster to TZQ;
grant alter any cube to TZQ;
grant alter any cube dimension to TZQ;
grant alter any dimension to TZQ;
grant alter any edition to TZQ;
grant alter any evaluation context to TZQ;
grant alter any index to TZQ;
grant alter any indextype to TZQ;
grant alter any library to TZQ;
grant alter any materialized view to TZQ;
grant alter any mining model to TZQ;
grant alter any operator to TZQ;
grant alter any outline to TZQ;
grant alter any procedure to TZQ;
grant alter any role to TZQ;
grant alter any rule to TZQ;
grant alter any rule set to TZQ;
grant alter any sequence to TZQ;
grant alter any sql profile to TZQ;
grant alter any table to TZQ;
grant alter any trigger to TZQ;
grant alter any type to TZQ;
grant alter database to TZQ;
grant alter profile to TZQ;
grant alter resource cost to TZQ;
grant alter rollback segment to TZQ;
grant alter session to TZQ;
grant alter system to TZQ;
grant alter tablespace to TZQ;
grant alter user to TZQ;
grant analyze any to TZQ;
grant audit any to TZQ;
grant audit system to TZQ;
grant backup any table to TZQ;
grant become user to TZQ;
grant change notification to TZQ;
grant comment any mining model to TZQ;
grant comment any table to TZQ;
grant create any assembly to TZQ;
grant create any cluster to TZQ;
grant create any context to TZQ;
grant create any cube to TZQ;
grant create any cube build process to TZQ;
grant create any cube dimension to TZQ;
grant create any dimension to TZQ;
grant create any directory to TZQ;
grant create any edition to TZQ;
grant create any evaluation context to TZQ;
grant create any index to TZQ;
grant create any indextype to TZQ;
grant create any job to TZQ;
grant create any library to TZQ;
grant create any materialized view to TZQ;
grant create any measure folder to TZQ;
grant create any mining model to TZQ;
grant create any operator to TZQ;
grant create any outline to TZQ;
grant create any procedure to TZQ;
grant create any rule to TZQ;
grant create any rule set to TZQ;
grant create any sequence to TZQ;
grant create any sql profile to TZQ;
grant create any synonTZQ to TZQ;
grant create any table to TZQ;
grant create any trigger to TZQ;
grant create any type to TZQ;
grant create any view to TZQ;
grant create assembly to TZQ;
grant create cluster to TZQ;
grant create cube to TZQ;
grant create cube build process to TZQ;
grant create cube dimension to TZQ;
grant create database link to TZQ;
grant create dimension to TZQ;
grant create evaluation context to TZQ;
grant create external job to TZQ;
grant create indextype to TZQ;
grant create job to TZQ;
grant create library to TZQ;
grant create materialized view to TZQ;
grant create measure folder to TZQ;
grant create mining model to TZQ;
grant create operator to TZQ;
grant create procedure to TZQ;
grant create profile to TZQ;
grant create public database link to TZQ;
grant create public synonTZQ to TZQ;
grant create role to TZQ;
grant create rollback segment to TZQ;
grant create rule to TZQ;
grant create rule set to TZQ;
grant create sequence to TZQ;
grant create session to TZQ;
grant create synonTZQ to TZQ;
grant create table to TZQ;
grant create tablespace to TZQ;
grant create trigger to TZQ;
grant create type to TZQ;
grant create user to TZQ;
grant create view to TZQ;
grant debug any procedure to TZQ;
grant debug connect session to TZQ;
grant delete any cube dimension to TZQ;
grant delete any measure folder to TZQ;
grant delete any table to TZQ;
grant dequeue any queue to TZQ;
grant drop any assembly to TZQ;
grant drop any cluster to TZQ;
grant drop any context to TZQ;
grant drop any cube to TZQ;
grant drop any cube build process to TZQ;
grant drop any cube dimension to TZQ;
grant drop any dimension to TZQ;
grant drop any directory to TZQ;
grant drop any edition to TZQ;
grant drop any evaluation context to TZQ;
grant drop any index to TZQ;
grant drop any indextype to TZQ;
grant drop any library to TZQ;
grant drop any materialized view to TZQ;
grant drop any measure folder to TZQ;
grant drop any mining model to TZQ;
grant drop any operator to TZQ;
grant drop any outline to TZQ;
grant drop any procedure to TZQ;
grant drop any role to TZQ;
grant drop any rule to TZQ;
grant drop any rule set to TZQ;
grant drop any sequence to TZQ;
grant drop any sql profile to TZQ;
grant drop any synonTZQ to TZQ;
grant drop any table to TZQ;
grant drop any trigger to TZQ;
grant drop any type to TZQ;
grant drop any view to TZQ;
grant drop profile to TZQ;
grant drop public database link to TZQ;
grant drop public synonTZQ to TZQ;
grant drop rollback segment to TZQ;
grant drop tablespace to TZQ;
grant drop user to TZQ;
grant enqueue any queue to TZQ;
grant execute any assembly to TZQ;
grant execute any class to TZQ;
grant execute any evaluation context to TZQ;
grant execute any indextype to TZQ;
grant execute any library to TZQ;
grant execute any operator to TZQ;
grant execute any procedure to TZQ;
grant execute any program to TZQ;
grant execute any rule to TZQ;
grant execute any rule set to TZQ;
grant execute any type to TZQ;
grant execute assembly to TZQ;
grant export full database to TZQ;
grant flashback any table to TZQ;
grant flashback archive administer to TZQ;
grant force any transaction to TZQ;
grant force transaction to TZQ;
grant global query rewrite to TZQ;
grant grant any object privilege to TZQ;
grant grant any privilege to TZQ;
grant grant any role to TZQ;
grant import full database to TZQ;
grant insert any cube dimension to TZQ;
grant insert any measure folder to TZQ;
grant insert any table to TZQ;
grant lock any table to TZQ;
grant manage any file group to TZQ;
grant manage any queue to TZQ;
grant manage file group to TZQ;
grant manage scheduler to TZQ;
grant manage tablespace to TZQ;
grant merge any view to TZQ;
grant on commit refresh to TZQ;
grant query rewrite to TZQ;
grant read any file group to TZQ;
grant restricted session to TZQ;
grant resumable to TZQ;
grant select any cube to TZQ;
grant select any cube dimension to TZQ;
grant select any mining model to TZQ;
grant select any sequence to TZQ;
grant select any table to TZQ;
grant select any transaction to TZQ;
grant under any table to TZQ;
grant under any type to TZQ;
grant under any view to TZQ;
grant unlimited tablespace to TZQ;
grant update any cube to TZQ;
grant update any cube build process to TZQ;
grant update any cube dimension to TZQ;
grant update any table to TZQ;

十一、创建Oracle Job任务,定时执行存过,实现自动处理数据比对结果自动推送到用户邮箱

11.1、创建Oracle Job任务,每天10:00执行

执行一下代码创建Oracle Job任务:

DECLARE
  job_num NUMBER;
BEGIN
  dbms_job.submit(job_num
                 ,'send_data_to_66;'
                 ,SYSDATE
                 ,'TRUNC(sysdate+1)+10/24'); --每天10:00执行
  COMMIT;
END;

11.2、立即执行一次Oracle Job任务

11.2.1、查找上一步创建好的job id

首先查找user_jobs视图找到上一步刚创建好的Oracle Job任务的JOB字段,是该job的id。
执行下面的命令查找用户下的所有Oracle Job任务:

SELECT * FROM user_jobs;

11.2.2、立即执行一次Oracle Job任务

传入job id,比如job id为6,则执行以下SQL脚本立即执行一次Oracle Job任务:

BEGIN
  dbms_job.run(6); -- 6 为 job id
  COMMIT;
END;

至此,Oracle处理数据比对自动推送方案 就讲解结束了,大家有不明白的地方可以给我留言,谢谢!

猜你喜欢

转载自blog.csdn.net/tttzzzqqq2018/article/details/132247316