PL / SQL重复

时间:2015-01-25 11:35:51

标签: sql oracle plsql

我正在sqlplus上执行以下PL / SQL脚本:

 declare
        cursor c is  select sal, empno, ename from emp where ((comm is null and sal>2000) or (comm is not null and (sal+comm)>2000));
              v_sal emp.sal%type;
              v_empno emp.sal%type;
              v_ename emp.ename%type;
             begin
              open c;
              loop
                 fetch c into v_sal,v_empno,v_ename;
                 insert into temp values(v_sal,v_empno,v_ename);
                 exit when(c%notfound);
              end loop;
              close c;
         end;
        /

我获得了我想要的所有n-uplets,但最后一个是重复的。

1 个答案:

答案 0 :(得分:2)

exit语句放在insert之前。