在存储过程中如何返回结果集

theoffspring 2009-10-14 08:13:01
我想在java中调用一个存储过程,就是一个查询而已,但不知怎么写,似乎有点麻烦,要用到游标啊。

查询是这样的:
create or replace procedure query_city_by_id(p_id in number ) is


begin
select * from system.city where cid=p_id;


end;
...全文
416 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
碧水幽幽泉 2009-10-18
  • 打赏
  • 举报
回复
create or replace procedure p_city_query_byid(
p_id in number ,
p_cursor out sys_refcursor
)
is
begin
open p_cursor for
select *
from system.city
where cid=p_id;
end;
或换成函数:
create or replace function f_city_query_byid(
p_id in number
)
return sys_refcursor
is
p_cursor sys_refcursor;
begin
open p_cursor for
select *
from system.city
where cid=p_id;
return p_cursor;
end;
seahi 2009-10-17
  • 打赏
  • 举报
回复
create or replace procedure query_city_by_id(
p_id in number ,
p_cursor out sys_refcursor
)
is begin
open p_cursor for
select * from system.city where cid=p_id;
end;
seahi 2009-10-17
  • 打赏
  • 举报
回复
create or replace procedure query_city_by_id(
p_id in number ,
p_cursor out sys_refcursor
)
is begin
open p_cursor for
select * from system.city where cid=p_id;
end;
theoffspring 2009-10-16
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 jiaruimin11 的回复:]
create or replace procedure query_city_by_id(p_id in number,p_cursor in out types.cursorType  ) is


begin
open p_cursor for  select * from system.city where cid=p_id;


end;
[/Quote]
types.cursorType这个需要声明一下吧
小灰狼W 2009-10-16
  • 打赏
  • 举报
回复
在过程里直接select ...要出错的
3楼的p_cursor in out types.cursorType -->p_cursor out sys_refcursor

system.city 。。怎么把表建到system用户下去了
bobocici 2009-10-16
  • 打赏
  • 举报
回复
通不过编译吧
jiaruimin11 2009-10-14
  • 打赏
  • 举报
回复

create or replace procedure query_city_by_id(p_id in number,p_cursor in out types.cursorType ) is


begin
open p_cursor for select * from system.city where cid=p_id;


end;
inthirties 2009-10-14
  • 打赏
  • 举报
回复
[Quote=引用楼主 theoffspring 的回复:]
我想在java中调用一个存储过程,就是一个查询而已,但不知怎么写,似乎有点麻烦,要用到游标啊。

查询是这样的:
create or replace procedure query_city_by_id(p_id in number ) is
 
     
begin
  select * from system.city where cid=p_id;


end;
[/Quote]

这个sp,没有问题,不过没有意义。

没有out参数,在plsql block里又没有dml语句。
shiyiwan 2009-10-14
  • 打赏
  • 举报
回复
这个存储过程写点有点问题

编译应该不会通过的。
http://blog.csdn.net/sparadise1003/archive/2009/01/12/3758331.aspx

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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