定义好的光标可以改变其内容再使用吗?

InsideJava 2002-04-24 01:22:19
create or replace procedure GL_loss_profit_company
(
v_CompId varchar2
)
as
v_tmp varchar2(20);
v_ProfitVoucher varchar2(20);
cursor tmp_cursor
is
select fja06c
from fjm01
where fja00c = v_CompId ;
begin
open tmp_cursor;
fetch tmp_cursor into v_tmp;
while (tmp_cursor%found) loop
v_ProfitVoucher := v_tmp;
-- 此处省略N行
fetch tmp_cursor into v_tmp;
END loop;
close tmp_cursor;

-- 问题就出在这儿,如何将tmp_cursor这个光标重新定义使用呢?
cursor tmp_cursor
is
select fia06c
from fim01
where fia00c = v_CompId ;
open tmp_cursor;
fetch tmp_cursor into v_tmp;
while (tmp_cursor%found) loop
v_ProfitVoucher := v_tmp;
-- 此处省略N行
fetch tmp_cursor into v_tmp;
END loop;
close tmp_cursor;
end GL_loss_profit_company;



还有一问: 定义好的光标如何将其杀掉呢?

...全文
99 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
InsideJava 2002-04-24
  • 打赏
  • 举报
回复
xzou,多谢
xzou 2002-04-24
  • 打赏
  • 举报
回复
不需要
InsideJava 2002-04-24
  • 打赏
  • 举报
回复
close tmp_cursor就可以释放资源了?
不需要杀掉它吗?
xzou 2002-04-24
  • 打赏
  • 举报
回复
就是close your_cursor就行了,不需要像sql server一样释放的
InsideJava 2002-04-24
  • 打赏
  • 举报
回复
Very Good!
xzou,you are right!

但是定义好的光标如何释放?
deallocate tmp_cursor;这样写不对!
这个问题解决了马上给分。

Oracle真是与众不同呀。
xzou 2002-04-24
  • 打赏
  • 举报
回复
oracle要这样写
CREATE OR REPLACE PACKAGE Pkg_MyType AS
TYPE T_MyCur IS REF CURSOR;
END Pkg_MyType;
/
SHOW ERRORS

create or replace procedure GL_loss_profit_company
(
v_CompId varchar2
)
as
v_tmp varchar2(20);
v_ProfitVoucher varchar2(20);
tmp_cursor Pkg_MyType.T_MyCur;
begin
open tmp_cursor for
select fja06c
from fjm01
where fja00c = v_CompId ;
fetch tmp_cursor into v_tmp;
while (tmp_cursor%found) loop
v_ProfitVoucher := v_tmp;
-- 此处省略N行
fetch tmp_cursor into v_tmp;
END loop;
close tmp_cursor;

open tmp_cursor for
select fia06c
from fim01
where fia00c = v_CompId ;
fetch tmp_cursor into v_tmp;
while (tmp_cursor%found) loop
v_ProfitVoucher := v_tmp;
-- 此处省略N行
fetch tmp_cursor into v_tmp;
END loop;
close tmp_cursor;
end GL_loss_profit_company;
InsideJava 2002-04-24
  • 打赏
  • 举报
回复
Oracle难道如此糟糕吗?
我想肯定不是的。

版主在吗?KingSunSha在吗?
快来救我。
InsideJava 2002-04-24
  • 打赏
  • 举报
回复
还有没有其它的人有其它的办法?

而且定义好的光标如何释放?
要知道close了并不是释放了。

SQL Server是这样释放的:
deallocate tmp_cursor;
InsideJava 2002-04-24
  • 打赏
  • 举报
回复
我就想在存储过程中重复定义使用该光标。
难道Oracle不能做到吗?那岂不是too poor!
bzszp 2002-04-24
  • 打赏
  • 举报
回复
你可以在写一个function,在里面执行
cursor tmp_cursor
is
select fia06c
from fim01
where fia00c = v_CompId ;
open tmp_cursor;
fetch tmp_cursor into v_tmp;
while (tmp_cursor%found) loop
v_ProfitVoucher := v_tmp;
-- 此处省略N行
fetch tmp_cursor into v_tmp;
END loop;
close tmp_cursor;
这样不行么?

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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