博客园

Oracle 中创建连接数据库及Job

 1 ---创建数据库连接
 2 CREATE PUBLIC DATABASE LINK DBL_ORCL CONNECT TO MEDCP IDENTIFIED BY MEDCP 
 3 USING '(DESCRIPTION =
 4 (ADDRESS_LIST =
 5 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.45)(PORT = 1521))
 6 )
 7 (CONNECT_DATA =
 8 (SERVICE_NAME=DOCAREEN)
 9 )
10 )';
11 
12 
13 --测试连接数据库
14 SELECT T.CLASS_CODE COSTTYPEID , T.CLASS_CODE COSTMAINTYPE,T.CLASS_NAME COSTTYPENAME , T.SERIAL_NO SORT FROM BILL_ITEM_CLASS_DICT@DBL_ORCL T WHERE T.CLASS_CODE  NOT IN(SELECT COSTTYPEID FROM  MED_COSTTYPE);
15 
16 
17 --创建定时任务
18 
19 DECLARE
20  
21 JOBNO NUMBER; --通过查看该变量可以得到返回的作业编号
22 
23 BEGIN
24  
25 DBMS_JOB.SUBMIT(
26  
27 JOBNO,
28  
29 'INSERT INTO MED_COSTTYPE (COSTTYPEID, COSTMAINTYPE, COSTTYPENAME, SORT)
30  SELECT T.CLASS_CODE COSTTYPEID , T.CLASS_CODE COSTMAINTYPE,T.CLASS_NAME COSTTYPENAME ,
31  T.SERIAL_NO SORT FROM BILL_ITEM_CLASS_DICT@DBL_ORCL T WHERE T.CLASS_CODE 
32  NOT IN(SELECT COSTTYPEID FROM  MED_COSTTYPE);', --执行工信局提供数据的脚本程序
33  
34 SYSDATE, --现在执行
35  
36 'SYSDATE+1' 
37 
38 );
39  
40 END;
41 
42  

 

posted @ 2012-11-08 20:41  一心一意  阅读(590)  评论(0编辑  收藏  举报

Powered by:
一心一意
Copyright & JGuang