请问这样的游标变量怎么用?
我写了一个存储过程,其中要用到游标,我使用游标变量时老是编译出错。代码如下
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;