Oracle学习之:存储过程/函数
2019-06-29 22:59
1096 查看
一、存储过程:
类似java中的方法,这个方法保存在oracle中,调用这个方法可以执行数据库的相关操作。
创建一个存储过程:
返回普通类型:
--创建 create or replace procedure hb_add ( num1 in number, num2 in number, out_num out number ) is begin out_num := num1 + num2; end hb_add; --调用 declare outnum number; begin hb_add(1,2,outnum); dbms_output.put_line(outnum); end;
返回游标类型:
create or replace procedure hb_outp ( str in varchar2, outproduct out sys_refcursor --返回游标 ) is --可换成as,和is无区别 ptype varchar2(2); begin ptype := str; open outproduct for select * from hb_product p where p.ptype = str;--可换成ptype end hb_outp;
二、函数
--创建 create or replace function f_add ( num1 in number, num2 in number ) return number --定义返回值类型 is --is或as out_num number; begin out_num := num1 + num2; return out_num; end f_add; --测试 select f_add(1,2) from dual;
相关文章推荐
- oracle 日期函数命令学习二
- Oracle函数学习
- oracle学习总结------函数的使用
- Oracle 学习之窗口函数(over)
- Oracle 中的PL/SQL基础、存储过程、触发器、函数、包(学习笔记)
- oracle学习 第四章 单行函数 ——02
- oracle 存储过程和函数学习笔记
- Oracle学习记录1(单行函数,多行函数)
- ORACLE函数学习(自学)
- oracle学习(五)--数字类型操作函数
- Oracle分析函数学习
- ORACLE PL/SQL子程序--过程和函数学习笔记
- Oracle学习记录之使用自定义函数和触发器实现主键动态生成
- oracle函数学习二(字符型函数)
- oracle函数学习
- Oracle学习之一——函数
- ORACLE学习第七篇(常用处理函数)
- Oracle分析函数学习笔记
- Oracle学习记录1(单行函数,多行函数)
- oracle逐步学习总结之oracle数字函数和日期函数(基础四)