表A 字段 W
表B 字段 ID L1 L2 TIME
表C 字段 L3 L4 
要求:A 的 W = B 的 ID ,(根据参数 =B的 TIME)查出 L1 L2 的量,插入 C 的 L3 L4
,若此时间 C 的L3 L4 数据已存在,先删除再插入。 就一个参数 @TIME 

解决方案 »

  1.   

    create table a
    (
    w varchar2(10)
    );create table b
    (
    id varchar2(10),
    l1 varchar2(10),
    l2 varchar2(10),
    time date
    );create table c
    (
    l3 varchar2(10),
    l4 varchar2(10)
    );create or replace precedure prc_insert
    (
    @time in date
    )
    is
    begin
    for r_1 in (select * from b where b.time = @time) loop
      delete from c where l3 = r_1.l1 and l4 = r_1.l2;
      insert into c values (r_1.l1,r_1.l2);
    end loop;
    commit;
    end;