返回多条记录时出错!

beibei4long 2003-09-15 11:43:17
create or replace procedure SOLVE_STEP_SELECT(StartTime in varchar2,
EndTime in varchar2) is
cursor cur_step_solve is
select * from manager.cd_step_solve;
step_solve cur_step_solve%rowtype;
begin
select *
into step_solve
from manager.cd_step_solve
where (to_char(RecvDateTime, 'yyyy/mm/dd')) >= StartTime and
to_char(RecvDateTime, 'yyyy/mm/dd') < EndTime;
end if;
end SOLVE_STEP_SELECT;

提示: hint:cursor'cur_step_solve' is declared but never used in 'solve_step_select'
但我要是不定义游标,又没法存返回的结果了,该怎么办啊?
...全文
25 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ColinGan 2003-09-15
  • 打赏
  • 举报
回复
你只需打开游标和关闭游标就可以,不用循环操作
程序如下:
create or replace procedure SOLVE_STEP_SELECT(StartTime in varchar2,
EndTime in varchar2) is
cursor cur_step_solve is
select * from manager.cd_step_solve;
step_solve cur_step_solve%rowtype;
begin
open cur_step_solve;
select *
into step_solve
from manager.cd_step_solve
where (to_char(RecvDateTime, 'yyyy/mm/dd')) >= StartTime and
to_char(RecvDateTime, 'yyyy/mm/dd') < EndTime;
close cur_step_solve;
end;
beibei4long 2003-09-15
  • 打赏
  • 举报
回复
谢谢nichotaz:
能就这个例子具体写出来吗?,我的意思只是要实现这个select 语句,不是存结果啊!
nicholaz 2003-09-15
  • 打赏
  • 举报
回复
你可以在package中定义一个ref cursor.

或者你要这样写的话,要写成
begin
open cur_step_solve;
loop
fetch cur_step_solve into ......;
exit when cur_step_solve%notfound;
.....
end loop;
close cur_step_solve;
end SOLVE_STEP_SELECT;
beibei4long 2003-09-15
  • 打赏
  • 举报
回复
谢谢浪子!
ColinGan 2003-09-15
  • 打赏
  • 举报
回复
增加一个特殊条件,比如rownum < 1等

程序如下:
create or replace procedure SOLVE_STEP_SELECT(StartTime in varchar2,
EndTime in varchar2) is
cursor cur_step_solve is
select * from manager.cd_step_solve
where rownum < 1;
step_solve cur_step_solve%rowtype;
begin
open cur_step_solve;
select *
into step_solve
from manager.cd_step_solve
where (to_char(RecvDateTime, 'yyyy/mm/dd')) >= StartTime and
to_char(RecvDateTime, 'yyyy/mm/dd') < EndTime;
close cur_step_solve;
end;
beibei4long 2003-09-15
  • 打赏
  • 举报
回复
请大家帮忙看看啦
beibei4long 2003-09-15
  • 打赏
  • 举报
回复
谢谢浪子:
想再问,怎么可以让cur_step_solve 使用之前里面是空的,只是用来装
into step_solve
from manager.cd_step_solve
where (to_char(RecvDateTime, 'yyyy/mm/dd')) >= StartTime and
to_char(RecvDateTime, 'yyyy/mm/dd') < EndTime;
的结果?
或者说怎样定义一个空游标?

17,377

社区成员

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

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