少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks
          廢話少說,首先建表:
          -- Create table
          create table ABIN4
          (
            ID1         NUMBER,
            NAME1       NVARCHAR2(100),
            CREATETIME1 DATE
          )
          tablespace SYSTEM
            pctfree 10
            pctused 40
            initrans 1
            maxtrans 255
            storage
            (
              initial 64K
              next 1M
              minextents 1
              maxextents unlimited
            );



          -- Create table
          create table ABIN5
          (
            ID1         NUMBER,
            NAME1       NVARCHAR2(100),
            CREATETIME1 DATE
          )
          tablespace SYSTEM
            pctfree 10
            pctused 40
            initrans 1
            maxtrans 255
            storage
            (
              initial 64K
              next 1M
              minextents 1
              maxextents unlimited
            );



          建立表遷移存儲過程(如果表abin5里面已經存在abin4里面遷移過來的記錄,那么就不再執行插入操作):

          create or replace procedure abing
          is
          begin
          declare
          cursor mycur is select t.id1,t.name1,t.createtime1 from abin4 t;
          sid abin4.id1%type;
          sname abin4.name1%type;
          screatetime abin4.createtime1%type;
          num number;
          begin
          open mycur;
          loop
          fetch mycur into sid,sname,screatetime;
          select count(*) into num from abin5 t where t.id1=sid and t.name1=sname and t.createtime1=screatetime;
          if(num=0) then
          insert into abin5 (id1,name1,createtime1) values (sid,sname,screatetime);
          end if;
          exit when mycur%NOTFOUND;
          commit;

          end loop;
          close mycur;
          end;
          end;



          建立Oracle定時器Job,讓系統定時的去執行操作:
          declare
          myjob1 number;
          begin
          sys.dbms_job.submit(myjob1,'abing;',sysdate,'sysdate+1/2880');
          commit;
          end;
          posted on 2012-08-02 12:23 abin 閱讀(1071) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 江口县| 土默特右旗| 香格里拉县| 榆社县| 枞阳县| 津南区| 丹棱县| 福鼎市| 理塘县| 左云县| 广水市| 绥江县| 新丰县| 手游| 太原市| 抚远县| 金山区| 耒阳市| 石屏县| 资阳市| 潼南县| 乐昌市| 万安县| 永吉县| 阿拉尔市| 民和| 县级市| 乐安县| 河曲县| 镇雄县| 祁门县| 马关县| 曲阳县| 资源县| 棋牌| 舞钢市| 宁南县| 万全县| 通化市| 汝阳县| 双流县|