存储过程,存储函数
数据库对象
存储在数据库中供所有用户调用的子程序叫做存储过程,存储函数
--存储过程 打印helloworld
/*
调用存储过程的方式
1.exec pro_say_helloworld();
2begin
pro_say_helloworld();
end;
*/
create procedure pro_say_helloworld
as
--说明部分
begin
dbms_output.put_line('helloworld!');
end;
--调用存储过程
begin
pro_say_helloworld();
pro_say_helloworld();
end;
--创建一个带参数的存储过程
--给指定员工涨100元工资,并且打印涨钱和涨后的薪水
drop procedure pro_RaiseSalry;
create or replace procedure pro_RaiseSalary(eno in number)
as
psal emp.sal%type;--定义一个变量保存涨薪水之前的工资
begin
select sal into psal from emp where id=eno;
update emp set sal = sal +100 where id=eno;
DBMS_OUTPUT.PUT_LINE('涨工资前的薪水'||psal||'涨工资后的薪水'||(psal+100));
end;
--注意 !! 一般不在存储过程或者存储函数中提交事务和回滚
begin
pro_RaiseSalary(1);
commit;
end;