标签: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