oracle 在一个存储过程中调用另一个返回游标的存储过程
2011-12-14 16:20
489 查看
实际项目当中经常需要在一个存储过程中调用另一个存储过程返回的游标,本文列举了两种情况讲述具体的操作方法。
第一种情况:返回的游标是某个具体的表或视图的数据
create or replace procedure p_testa(presult out sys_refcursor) as begin open presult for select * from users; end p_testa;其中 users 就是数据库中一个表(或视图)。在调用的时候只要声明一个该表的rowtype类型就可以了:
create or replace procedure p_testb as temp_cur sys_refcursor; r users%rowtype; begin p_testa(temp_cur); loop fetch temp_cur into r; exit when temp_cur%notfound; dbms_output.put_line(r.name); end loop; end p_testb;
第二种情况:我们返回的不是表的所有的列,或许只是其中一列或两列
create or replace procedure p_testa(presult out sys_refcursor) as begin open presult for select id, name from users; end p_testa;这里我们只返回了 users 表的 id, name 这两个列,那么调用的时候也必须做相应的修改:
create or replace procedure p_testb as temp_cur sys_refcursor; cursor cur_1 is select id, name from users where rownum = 1; r cur_1%rowtype; begin p_testa(temp_cur); loop fetch temp_cur into r; exit when temp_cur%notfound; dbms_output.put_line(r.id); end loop; end p_testb;
相关文章推荐
- oracle 在一个存储过程中调用另一个返回游标的存储过程
- oracle 在一个存储过程中调用另一个返回游标的存储过程
- (转载)oracle 在一个存储过程中调用另一个返回游标的存储过程
- oracle如何在一个存储过程中调用另一个返回游标的存储过程
- oracle 在一个存储过程中调用另一个返回游标的存储过程
- 在一个存储过程中调用返回一个游标的另一个存储过程
- Oracle 存储过程调用返回游标的另一个存储过程。
- jdbc中调用oracle 返回游标类型的存储过程
- java 调用oracle 分页存储过程 返回游标数据集
- jdbc中调用oracle 返回游标类型的存储过程
- Java调用oracle存储过程通过游标返回临时表数据
- Java调用oracle存储过程通过游标返回临时表数据
- JAVA调用ORACLE带数组输入参数和返回游标结果集的存储过程
- Java调用oracle存储过程通过游标返回临时表数据
- oracle调用返回游标的存储过程
- SQLServer和ORACLE 存储过程的调用(返回结果集)
- j2ee调用Oracle带数组参数和游标的存储过程方法
- java 调用oracle的存储过程返回记录集
- Sql server 跨服务器在一个存储过程sp_A中调用另一个存储过程sp_B
- 存储过程调用存储过程,存储过程调用函数,返回表表变量,游标使用