请问这样的游标变量怎么用?

liujiin 2003-03-13 05:06:57
我写了一个存储过程,其中要用到游标,我使用游标变量时老是编译出错。代码如下
create or replace procedure Pro_TwoPrice(sqlstr in varchar2)
is
v_sql varchar2(1000);
v_ErrorText varchar2(200);
type t_temphd is ref cursor return wxgh_temphd%ROWTYPE;
v_temphd t_temphd;

RecordId wxgh_temphd.recordid%type;
Yhbh wxgh_temphd.yhbh%type;
Call_Type wxgh_temphd.call_type%type;
Msisdn wxgh_temphd.msisdn%type;
Other_Party wxgh_temphd.other_party%type;
Start_Date wxgh_temphd.start_date%type;
Start_Time wxgh_temphd.start_time%type;
Call_Duration wxgh_temphd.call_duration%type;
Cell_Id wxgh_temphd.cell_id%type;
Trunk_Groupout wxgh_temphd.trunk_groupout%type;
Trunk_Groupin wxgh_temphd.trunk_groupin%type;
Roam_Type wxgh_temphd.roam_type%type;
User_Type wxgh_temphd.user_type%type;
City_Code wxgh_temphd.city_code%type;
Mob_City_Code wxgh_temphd.mob_city_code%type;
Opp_Area_Code wxgh_temphd.opp_area_code%type;
Is_Local wxgh_temphd.is_local%type;
Caller_Type wxgh_temphd.caller_type%type;
Caller_User_Type wxgh_temphd.caller_user_type%type;
Sfpj wxgh_temphd.sfpj%type;
Yhdh wxgh_temphd.dh%type;

begin
BEGIN
v_sql :='select * from wxgh_temphd where sfpj=0 '||sqlstr;
open v_temphd for v_sql;
LOOP
FETCH v_temphd into RecordId,Yhbh,Call_Type,Msisdn,Other_Party,Start_Date,Start_Time,Call_Duration,Cell_Id,
Trunk_Groupout,Trunk_Groupin,Roam_Type,User_Type,City_Code,Mob_City_Code,Opp_Area_Code,Is_Local,
Caller_Type,Caller_User_Type,Sfpj,Yhdh;

EXIT WHEN v_temphd%NOTFOUND;
END LOOP;
close v_temphd;
COMMIT;
END;
end Pro_TwoPrice;
...全文
84 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liujiin 2003-03-14
  • 打赏
  • 举报
回复
谢谢楼上两位,问题解决了。
beckhambobo 2003-03-13
  • 打赏
  • 举报
回复
多了一对begin ...end

看起来好累,为何不直接返回记录,而用变量。
Lastdrop 2003-03-13
  • 打赏
  • 举报
回复

type t_temphd is ref cursor return wxgh_temphd%ROWTYPE;
改为
type t_temphd is ref cursor ;
试试。

如果还有错误,最好给出错误信息。

17,377

社区成员

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

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