首页 > 学院 > 开发设计 > 正文

pl/sql编程(七) 判断

2019-11-08 20:43:29
字体:
来源:转载
供稿:网友

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

create or replace PRocedure sp1(spName varchar2) isv_sal emp.sal%type;beginselect sal into v_sal from emp where name=spName;if v_sal<2000 thenupdate emp set sal=sal+sal*0.2 where name=spName;elseupdate emp set sal=sal*1.1 where name=spName;end if;end;/

–编写一个过程,输入员工ID 如果部门是1 则工资增加300元,2号部门增加400,其他部门 否则增加100

create or replace procedure sp1(spNo number) isv_deptno emp.deptno%type;beginselect deptno into v_deptno from emp where id=spNo;if v_deptno=1 thenupdate emp set sal=sal+300 where id=spNo;elsif v_deptno=2 thenupdate emp set sal=sal+400 where id=spNo;elseupdate emp set sal=sal+100 where id=spNo;end if;end;/
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表