码迷,mamicode.com
首页 > 其他好文 > 详细

根据23423条件,截取字段‘abdecsdsadsadsad’,以ab/dec/sdsa/ds/ads 输出

时间:2014-12-11 00:16:44      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   os   sp   on   div   art   log   

create or replace procedure p_getString
(
    p_finalString out varchar2,
    p_rulestring  in number, 
    p_sourceString in varchar2
)
as
    v_num number:=1;
    v_resoucenum number:=1;
    v_getnum number;
    v_getsting varchar2(2000);
    v_errorstring exception;
    v_errorrule exception;
begin
     if length(p_sourceString) < 18 then
       raise v_errorstring;
     else
         p_finalString:=‘‘;
        loop
         v_getnum := substr(p_rulestring, v_num, 1);                     -- get the numbers from rule 
         v_getsting := substr(p_sourceString, v_resoucenum, v_getnum);   -- According to the rule number to get the short String 
         v_resoucenum := v_resoucenum + v_getnum;                        -- the number of the next short string start position
         v_num := v_num + 1;                                             
         p_finalString := p_finalString||v_getsting||‘/‘;                -- Splice the short string to the final String
         dbms_output.put_line(v_resoucenum);
         if substr(p_rulestring, v_num, 1) is null then exit;    
         end if;
        end loop;
         if (v_resoucenum -1) < 18 or(v_resoucenum -1) > 18 then 
            raise v_errorrule;
         end if;
         p_finalString := substr(p_finalString, 1, length(p_finalString)-1);
    end if;
    
exception
  when v_errorstring then
    p_finalString:=‘The String length is less than 18!‘;
  when v_errorrule then
    p_finalString:=‘The sum value of the rule numbers less than or more then 18!‘;
  when others then
    p_finalString:=‘Others wrong‘;
    
end p_getString;

  

根据23423条件,截取字段‘abdecsdsadsadsad’,以ab/dec/sdsa/ds/ads 输出

标签:blog   io   ar   os   sp   on   div   art   log   

原文地址:http://www.cnblogs.com/zhangwensi/p/4156588.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!