oracle自定义方法中使用游标

create or replace function GetSurveyList(in_CustId in varchar)
return varchar2
is
  Result varchar2(4000);
  v_acc_nbr varchar2(400);
  v_acc_nbr2 varchar2(400);

  type ref_cursor is ref cursor;
  v_cursor ref_cursor;
begin
  Result:='';
  open v_cursor for select user_id,username from sys_user where is_use=in_CustId;
  loop
    fetch v_cursor into v_acc_nbr,v_acc_nbr2;
    exit when v_cursor%notfound;
 -- if(tempCount>8) then
  --  goto label_end;
 -- end if;
  --Result:=v_acc_nbr||','||v_acc_nbr2||Result;
 -- tempCount := tempCount +1;
 if v_acc_nbr='58'
   then
   Result:=v_acc_nbr;
   goto label_end;
   end if;
  end loop;
   <<label_end>>
  close v_cursor;
  return(Result);
  exception
  when others then
  if(v_cursor%isopen) then
    close v_cursor;
  end if;
    return '';
end GetSurveyList;
 

猜你喜欢

转载自blog.csdn.net/yantaiwuyansong/article/details/88218202
今日推荐