第一个存储过程:
create or replace procedure p_Test is
begin
dbms_output.put_line('第一个procedure');
end p_Test;
2/ 输入值,输出值,number类型可以给varchar类型赋值;
create or replace procedure p_Test(a in varchar2,b out varchar2) is
num number := 99;
begin
b := num;
dbms_output.put_line(b);
end p_Test;
3/ if else 判断
create or replace procedure p_Test(a in varchar2,b out varchar2) is
num number := 70;
begin
if num > 99 then
b := 'A';
end if;
if num <60 then
b := 'C';
else
b := 'B';
end if;
dbms_output.put_line(b);
end p_Test;
4/ for 循环
create or replace procedure p_Test(a in varchar2,b out varchar2) is
num number := 0;
begin
for countNum in 0..10 loop
num := num+countNum;
end loop;
dbms_output.put_line(num);
end p_Test;
5/ 查询数据库表 返回值:
create or replace procedure p_Test(a in varchar2 ,b out varchar2) is
code varchar(100);
num number;
begin
select count(1) into num from sys_res_tree t where t.res_tree_id=a;
select t.tree_name into code from sys_res_tree t where t.res_tree_id=a;
dbms_output.put_line(code);
exception
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('error');
end p_Test;
6/游标 遍历游标
create or replace procedure p_Test(a in varchar2) is
code varchar2(200);
cursor cursor1 is
select t.* from sys_res_tree t where t.p_res_tree_id=a;
begin
for cursorresult in cursor1 loop
code := code||cursorresult.tree_name;--点游标里的对象
end loop;
dbms_output.put_line(code);
RETURN;--退出存储过程
end p_Test;
7/sys_refcursor游标使用方法
create or replace procedure p_Test is
cu sys_refcursor;
res_tree_id varchar2(30);
tree_name varchar2(30);
p_res_tree_id varchar2(30);
begin
open cu for select t.res_tree_id,t.tree_name,t.p_res_tree_id from sys_res_tree t;
loop
fetch cu into res_tree_id,tree_name,p_res_tree_id;
dbms_output.put_line(res_tree_id);
dbms_output.put_line(tree_name);
exit when cu%Notfound;
end loop;
end p_Test;
相关推荐
oracle存储过程学习经典入门 非常好的 初学者必看
oracle存储过程学习资料 oracle存储过程学习资料 oracle存储过程学习资料
oracle存储过程学习
ORACLE存储过程 学习源码,从简单到深奥,一共有30个文件。
存储过程学习、个人随笔、基本语法和流程控制。仅供参考
快速学习函数创建和练习。 创建函数、存储过程、创建过程、调用存储过程、AUTHID、PRAGMA AUTONOMOUS_TRANSACTION、开发存储过程步骤、删除过程和函数、过程与函数的比较
oracle存储过程学习经典[语法+实例+调用].doc
oracle 存储过程学习经典,主要适合初学oracle存储过程的.
oracle存储过程学习经典(实例),适合刚学习存储过程的广大程序员们
oracle存储过程学习经典[语法+实例+调用].pdf
oracle存储过程学习相关文档,包括使用手册,实例和经典语法等。
1.基本结构 CREATE OR REPLACE PROCEDURE 存储过程名字 ( 参数1 IN NUMBER, 参数2 IN NUMBER ) IS 变量1 INTEGER :=0; 变量2 DATE; BEGIN END 存储过程名字
不经典的我也不会发上来。我是推荐给大家。oracle存储过程学习经典语法+实例+调用。
该文档比较详细地介绍了Oracle存储过程,有例子
oracle存储过程学习经典oracle存储过程学习经典
oracle存储过程学习经典入门