create or replace procedure p_olddic_newdic is
  cursor commons is select t1.name codename from n_code t1, o_dictable t2
                     where t1.name = t2.dic_name;       oldcode varchar2(50);
  oldname varchar2(200);
  newid varchar2(50);
  newtext varchar2(200);
 
begin
  for common in commons loop
     begin
        dbms_output.put_line(common.codename);
        insert into old_new_dic_compare(OLDCODE,OLDNAME,NEWID,NEWTEXT)
        select t1.ocode, t1.oname, t2.nid, t2.ntext 
           from 
           (
             select e.code ocode,e.name oname from o_dic_columns e 
             where e.dic_id = (select t.dic_id from o_dictable t where t.dic_name=common.codename)
           ) t1
              full outer join
           (
             select e.id nid, e.text ntext from n_codeitem e 
             where e.codeid = (select t.id from n_code t where t.name=common.codename)
           ) t2
             on t1.oname = t2.ntext;
             commit;
        dbms_output.put_line('de');
      end;
  end loop;
end;

解决方案 »

  1.   

    换一个别名也不行,主要是from里面的子查询的where条件t.dic_name、t.name,这两个条件我需要让他们动态的变化,写死之后不会报错,写成游标当前值就会报缺少from,这个我不解??
      

  2.   

    (select t.dic_id from o_dictable t where t.dic_name=common.codename)
    (select t.id from n_code t where t.name=common.codename)
     
    你看看这两个是不是返回了多条记录。