oracle存储过程学习(-)-基本过程
来源:互联网 发布:网络安全法专家论证会 编辑:程序博客网 时间:2024/05/16 12:18
1.存储过程语法
create or replace procedure 存储过程名
is
begin
null;
end;
2.新建一个存储过程
create or replace procedure SELECT_PACT_TYPE is--定义变量pactTypeId number;typeName nvarchar2(100);begin select t.pact_type_id,t.pact_type_name into pactTypeId, typeName from crm_pact_type t where t.pact_type_id=2;--select into 赋值给变量 from dbms_output.put_line(pactTypeId || typeName);--调试输出 exception when no_data_found then null;--未查到数据 WHEN OTHERS THEN RAISE;end ;
3.如果查询多条数据,用游标,把上面的改进
create or replace procedure SELECT_PACT_TYPE is--定义变量pactTypeId number;typeName nvarchar2(100);--游标cursor c is select t.pact_type_id,t.pact_type_name from crm_pact_type t ;begin --循环游标 for cr in c loop begin --赋值 pactTypeId := cr.pact_type_id; typeName := cr.pact_type_name; dbms_output.put_line( pactTypeId || typeName ); end; end loop; exception when no_data_found then null;end ;
4.带参数的查询
create or replace procedure SELECT_PACT_TYPE(id in number)is--定义变量pactTypeId number;typeName nvarchar2(100);--游标cursor c is select t.pact_type_id,t.pact_type_name from crm_pact_type t where t.pact_type_id=id;begin --循环游标 for cr in c loop begin --赋值 pactTypeId := cr.pact_type_id; typeName := cr.pact_type_name; dbms_output.put_line( pactTypeId || typeName ); end; end loop; exception when no_data_found then null;end ;
5.调用上面带参数存储过程
declare i number;begin i:=2; -- 调用 id=>i id是存储过程的形参 ,i 是实际参数的值 ,将i的值赋给了id select_pact_type(id => i);end;
0 0
- oracle存储过程学习(-)-基本过程
- Oracle存储过程基本语法 存储过程
- oracle存储过程学习过程
- Oracle存储过程基本语法(一)
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- oracle 存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- Oracle 存储过程学习
- Oracle存储过程学习
- Oracle存储过程学习
- 马云控制恒生电子 意欲何为?
- SSD2828有 mipi 协议的读操作
- 真的是最后的最后了!
- UITableView 滚动流畅性优化
- Windows 远程桌面使用日志
- oracle存储过程学习(-)-基本过程
- PHP获得真实客户端的真实IP REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR
- Android JNI开发入门与提高
- LoadString()函数
- jquery实现页面滑动例子
- 配置sql2000远程数据库
- Android Camera 运行流程
- LAMP搭建错误总结
- hibernate关系注解映射