pl/sql进阶

Oracle的控制语句

1.条件语句:

  pl/sql 中提供了三种条件分支语句:

  if ... then ...

  if ... then ... else...

  if ...then ... elsif ... then ... else ...

a.简单的条件判断: if ... then ...

?编写一个过程,可以输入一个员工姓名,如果该员工的工资低于2000,就给该员工增加10%

  create or replace procedure pro_sal (myName varchar2) is

   v_sal emp.sal%type;

   begin

    select sal into v_sal from emp where ename = myName;

    if v_sal > 2000 then

      update emp ser sal = sal * 1.1 where ename  = myname;

   end;

 b.双重条件分支:if ... then ... else ...

 c. 多重条件分支:if ... then ... elsif ... then ... else ...

2.循环语句:

  loop ... end loop;

  while ... loop ... end loop;
  for i in [reverse] 1... 10 loop ... end;

posted @ 2011-04-26 15:08  zmt  阅读(430)  评论(1编辑  收藏  举报