oracle存储过程代码实例一
来源:互联网 发布:网络通信协议规格说明 编辑:程序博客网 时间:2024/05/21 06:12
1、用来插入大量测试数据的存储过程
CREATE OR REPLACE PROCEDURE INSERTAMOUNTTEST
(
ST_NUM IN NUMBER,
ED_NUM IN NUMBER
)
IS
BEGIN
declare
i number;
begin
FOR i IN ST_NUM..ED_NUM LOOP
INSERT INTO tb values(i,i,'3','3','3',100,'0');
END LOOP;
end;
END;
运行:
sql>execute INSERTAMOUNTTEST(1,45000) -- 一次插入45000条测试数据
2、从存储过程中返回值
create or replace procedure spaddflowdate
(
varAppTypeId in varchar2,
varFlowId in varchar2,
DateLength in number,
ReturnValue out number --返回值
)
is
begin
insert into td values(varAppTypeId,varFlowId,DateLength)
returning 1 into ReturnValue; --返回值
commit;
exception
when others then
rollback;
end;
存储过程的执行
sql>variable testvalue number;
sql>execute spaddflowdate('v','v',2,:testvalue);
sql>print
就可以看到执行结果
3、用包实现存储过程返回游标:
create or replace package test_p
as
type outList is ref cursor;
PROCEDURE getinfor(taxpayerList out outList);
end test_p;
/
create or replace package body test_p as PROCEDURE getinfor(taxpayerList out outList) is begin
OPEN taxpayerList FOR select * from
td where tag='0';
end getinfor;
end test_p;
/
运行:
set serverout on; --将输出工具打开
variable x refcursor;
execute test_p.getinfor(:x);
exec test_p.getinfor(:x);
print x;
drop package test_p;
- oracle存储过程代码实例一
- oracle存储过程代码实例一
- oracle存储过程代码实例一
- oracle存储过程代码实例
- oracle存储过程代码实例
- Oracle 存储过程实例
- Oracle存储过程实例
- oracle 存储过程实例
- oracle存储过程实例
- Oracle存储过程实例
- Oracle存储过程实例
- Oracle存储过程实例
- oracle存储过程实例
- Oracle存储过程实例
- oracle存储过程实例
- oracle存储过程实例
- oracle存储过程实例
- oracle存储过程实例
- Linux的配置文件
- PO BO VO DTO POJO DAO概念及其作用(附转换图)
- JAVA XML教程
- Boost智能指针——weak_ptr .
- build.xml文档模板
- oracle存储过程代码实例一
- 二分图带权匹配问题
- 《我的泛型编程观》之boost.scoped_ptr、scoped_array源码分析
- js实现点击显示效果[select]
- 华为三道上机题解答
- android 触摸(Touch)事件、点击(Click)事件的区别(详细解析)
- Java基础:从C++转到Java需注意的地方
- QNX 中的线程休眠
- soaoffice对wps的支持到底怎样