要过程干什么?一句sql解决
insert into bigtable(决算入力区分CODE,格付方式CODE,财务比率)
select b.决算入力区分CODE,b.格付方式CODE,c.财务比率
  from zh a, tj b, kt c
 where a.顾客CODE = b.顾客CODE
   and a.决算期日 = b.决算期日
   and b.决算入力区分CODE = c.决算入力区分CODE (+)
   and b.格付方式CODE = c.格付方式CODE (+)
   and ...btw,你的字段名好难理解

解决方案 »

  1.   

    create or replace procedure name(....)
    as 
    declare
    cursor t_sor is
    select b.决算入力区分CODE,b.格付方式CODE,b.财务比率
    from zh a, tj b
    where a.顾客CODE = b.顾客CODE  and a.决算期日 = b.决算期日;cursor l_sor(p1 tj.决算入力区分CODE%type,p2 tj.格付方式CODE%type) is
    select c.决算入力区分CODE,c.格付方式CODE,c.财务比率
    from  kt c
    where 决算入力区分CODE = p1   and 格付方式CODE = p2;v_sor t_sor%rowtype;
    begin
    open t_sor;
    fetch t_sor into v_sor;
    if t_sor%notfound then
    insert into bigtable select 决算入力区分CODE,格付方式CODE,null from TJ;
    else
    loop
    exit when t_sor%notfound;
    for m_sor in l_sor(v_sor.决算入力区分CODE,v_sor.格付方式CODE) loop
    insert into bigtable values(m_sor.决算入力区分CODE,m_sor.格付方式CODE,m_sor.财务比率);
    end loop;
    fetch t_sor into v_sor;
    end loop;
    end if;
    colse t_sor;
    end;
    /
    看过程是否与你的意思有出入?