PLSQL

    技术2022-05-20  47

     declare --声明一个游标类型 type mycur is ref cursor; --声明一个游标变量,将类型实例化 cur mycur; v_name emp.ename%type; v_job  emp.job%type;  begin   select job into v_job from emp where empno='111';   if v_job = 'saler' then     --为游标指定一个结果集     open cur for select ename from emp where sal<3000;   else     --为游标指定一个结果集     open cur for select ename from emp where sal>3000;   end if;   --提取   while cur%found loop     dbms_output.put_line(v_name);     fetchcur into v_name;   end loop;     --关闭   close cur; exception   when others then     dbms_output.put_line(sqlcode||sqlerrm); end; 


    最新回复(0)