一、自定义函数
- 创建自定义函数
create or replace function 函数名 return 返回值的类型 as
begin
函数定义
end 函数;
- 在数据字典中查看自定义函数的信息
与之相关的视图主要有两个:user_objects与user_source - 调用函数
函数名()
- 函数的参数
create or replace function 函数名(数据类型1 参数1,数据类型2 参数2...) return 返回值的类型 as
begin
函数定义
end 函数;
- 返回值的类型后面+deterministic ——设置函数的确定性;保证传入参数相同时,不执行函数,从缓存中获得正确结果
2、典型函数 (row2column )——行转列
二、存储过程
- 格式
create or replace procedure 存储过程名称 as
begin
存储过程定义
end 存储过程名称
其中存储过程定义是一组PL/SQL代码。
- 创建存储过程
create or replace procedure updateStatus as
begin
update students set status='ACT';
commit
end updateStatus;
/
- 查看存储过程信息