现在有张视图v_xh 里面的 XH 字段 跟t_ss表的XH字段是唯一的,
现在要求写个存储过程,要把t_ss 表里面的XH 跟V_XH 的学号一样的话 就插入另外一张表T_DD
 insert into t_dd values(wid,‘’,‘’,取t_ss里面的XH,取t_ss里面的SSBH,‘’,‘’,‘2010-07-01’,‘3’,‘张三’,‘2010-07-01’,'固定')
然后删除T_SS里面的XH相同的数据,在线等急!
然后再建个JOB 每天去调用这个存储过程执行一次。

解决方案 »

  1.   

    CREATE OR REPLACE PROCEDURE pro_test
    AS
    BEGIN
       INSERT INTO t_dd
                   (字段名)
          SELECT wid, '', '', t_ss.xh, t_ss.ssbh, '', '', ‘2010 - 07 - 01 ’,
                 ‘3’, ‘张三’, ‘2010 - 07 - 01 ’, '固定'
            FROM t_ss, t_xh
           WHERE t_ss.xh = t_xh.xh;   DELETE FROM t_ss
             WHERE xh IN (SELECT xh
                            FROM t_ss, t_xh
                           WHERE t_ss.xh = t_xh.xh);
    END;大致写了一个,由于你没有给出表结构及结果,所以无法详细写,还有你建JOB每天调查用是指用Oracle作业调度还是用其它工具实现?
      

  2.   

    /*
       创建存储过程
    */
    create or replace procedure mg122623
    is
    begin
    --插入数据
    insert into T_DD 
    select 1,'','',a.xh,a.ssbh,'','',sysdate,'3','张三',sysdate,'固定' from t_ss a,v_xh b
    where a.xh = b.xh;commit;
    --删除数据
    delete  from t_ss 
    where xh in (select a.xh from t_ss a,v_xh b where a.xh=b.xh);commit;end mg122623;/*
      创建job
    */
    VARIABLE jobno number;
    begin
    dbms_job.submit(:jobno,'mg122623;',sysdate,'trunc(sysdate + 1)');
    commit;
    end;