a need
For the designated employees, increase the salary of 100 yuan; and print the salary before and after the increase.
two code
--带参数存储过程:给指定的员工涨100,并且打印涨前和涨后的薪水
/*
如何调用:
begin
raisesalay(7839);
raisesalay(7566);
commit;
end;
/
*/
create or replace procedure raisesalay(eno in number)
as
--定义一个变量保存涨前的薪水
psal emp.sal%type;
begin
select sal into psal from emp where empno=eno;
update emp set sal=sal+100where empno=eno;
--需不需要commit?
--注意:一般不在存储过程或存储函数中提交和回滚,由调用者来进行提交或回滚
dbms_output.put_line('涨前:'||psal||'涨后:'||(psal+100));
end;
/
Three calls to the stored procedure
SQL> begin
2 raisesalay(7839);
3 raisesalay(7566);
4 commit;
5 end;
6 /
Before rising: 10000 After rising: 10100
Before the rise: 6975 After the rise: 7075
PL/SQL procedure completed successfully.