• Oracle之函数中使用游标


    create or replace function getcustprodinstaddr(in_CustId in number,in_area_code in number) 
    return varchar2 
    is
      Result varchar2(4000);
      v_acc_nbr varchar2(400);
      tempCount number:=1;
      type ref_cursor is ref cursor;
      v_cursor ref_cursor;
    begin
      Result:='';
      open v_cursor for 
      'select install_addr from tb_prd_prd_inst_'||to_char(in_area_code)||
      ' where PRD_INST_STAS_ID not in(''1003'',''1101'',''1401'',''1102'') 
      and own_cust_id='||to_char(in_CustId)||' order by install_date desc';
      loop
        fetch v_cursor into v_acc_nbr;
        exit when v_cursor%notfound;
    	if(tempCount>8) then
    		goto label_end;
    	end if;
    	Result:=v_acc_nbr||','||Result;
    	tempCount := tempCount +1;
      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 getcustprodinstaddr;

  • 相关阅读:
    c#判断输入的是不是数字
    params 关键字载入空值的陷阱
    拆箱陷阱
    接口的概念和声明
    数据库
    ios 纵向的UISlider
    微信小程序学习网站
    Spark RDD(2)
    SparkSql
    廖雪峰老师学习网站
  • 原文地址:https://www.cnblogs.com/archermeng/p/7537396.html
Copyright © 2020-2023  润新知