当前位置:Gxlcms > 数据库问题 > oracle 游标

oracle 游标

时间:2021-07-01 10:21:17 帮助过:17人阅读

serveroutput on DECLARE CURSOR cemp is select ename ,sal from emp ; pename emp.ename%TYPE ; psal emp.sal%TYPE ; BEGIN OPEN cemp; LOOP FETCH cemp INTO pename,psal; EXIT WHEN cemp%notfound; dbms_output.put_line(pename||的薪水是||psal); END LOOP; CLOSE cemp; END;

 

set serveroutput on

DECLARE

  CURSOR cemp is select empno ,job from emp ;
  pempno emp.empno%TYPE ;
  pjob emp.job%TYPE ;

  BEGIN

  OPEN cemp;
  LOOP
    FETCH  cemp INTO pempno,pjob;
    EXIT  WHEN cemp%notfound;

   if pjob=PRESIDENT  then update emp set sal=sal+1000 where empno=pempno;
    elsif pjob=MANAGER  then update emp set sal=sal+8000 where empno=pempno;
     else  update emp set sal=sal+5000 where empno=pempno;
end if;
  END LOOP;


  CLOSE cemp;
  
  commit;
END;



select  * from emp

 

oracle 游标

标签:otf   class   man   declare   out   lin   weight   oracle   style   

人气教程排行