◆oracle9i 存储过程返回数据集的写法?◆

ChinaOneCup 2012-11-27 10:51:52
比如就写:
select userid,username from usertbl where place = in_place; //in_place为传过来的参数


请问有几种办法能返回数据集的
...全文
124 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuan.ye 2012-11-29
  • 打赏
  • 举报
回复
6# 搞错了,没看清是 oracle ,sorry
xuan.ye 2012-11-29
  • 打赏
  • 举报
回复
正常select 就可以,无外乎就是 select之后可能会需要一个 commit;
forgetsam 2012-11-28
  • 打赏
  • 举报
回复
引用 4 楼 ChinaOneCup 的回复:
引用 3 楼 forgetsam 的回复:我忘了9i有没有sys_refcursor了,如果没有,自己建立一个包,包里面声明一个弱游标类型就可以了。 9i有sys_refcursor,在sqlplus执行该存储过程为何没有数据显示的呢
游标不会动态显示,这种游标是需要传出的,显示它干什么? 如果要检验,open result1 然后自己循环打印。 等你把数据都打印完了,这个游标也就不可用了。
ChinaOneCup 2012-11-27
  • 打赏
  • 举报
回复
引用 3 楼 forgetsam 的回复:
我忘了9i有没有sys_refcursor了,如果没有,自己建立一个包,包里面声明一个弱游标类型就可以了。


9i有sys_refcursor,在sqlplus执行该存储过程为何没有数据显示的呢
forgetsam 2012-11-27
  • 打赏
  • 举报
回复
我忘了9i有没有sys_refcursor了,如果没有,自己建立一个包,包里面声明一个弱游标类型就可以了。
ChinaOneCup 2012-11-27
  • 打赏
  • 举报
回复
//怎么用sqlplus运行显示数据
create or replace procedure GetUser (result1 out sys_refcursor)
as 
begin
  open result1 for select userid,username from usertbl;
end;
ChinaOneCup 2012-11-27
  • 打赏
  • 举报
回复
我这样写为何有错误提示呢
CREATE OR REPLACE PROCEDURE Proc_Test(Vx  out REF CURSOR)
is
  cursor mycursor is select userid,username from usertbl;
begin
  open mycursor ;
  while mycursor %found loop
    fetch mycursor into Vx;
  end loop;
  close mycursor;
end;

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧