ITPub博客

首页 > 数字化转型 > ERP > 单字节处理函数

单字节处理函数

原创 ERP 作者:xypincle 时间:2017-02-19 21:24:26 0 删除 编辑

  1. CREATE OR REPLACE Function ZL_GetSinglebyte_string
  2. (
  3.   strValue_IN varchar2,
  4.   numValue_IN number
  5. )
  6. Return Varchar2 Is
  7.    v_temp varchar2(200);
  8.    v_return varchar2(200);
  9.    v_num number:=0;
  10.    v_sum number:=0;
  11.    idx number :=1 ;
  12.    idy number :=0 ;
  13. BEGIN
  14.   IF lengthb(strValue_IN)>=numValue_IN then
  15.       WHILE idx <= LENGTH(strValue_IN) LOOP
  16.          v_temp := SUBSTR(strValue_IN,idx,1);
  17.          v_num := v_num + lengthb(v_temp);
  18.          if v_num > numValue_IN then
  19.             v_return := v_return||substr(strValue_IN,1,idx-1)||' ';
  20.             exit;
  21.          elsif v_num = numValue_IN then
  22.             v_return := v_return||substr(strValue_IN,1,idx);
  23.             exit;
  24.          else
  25.             idx := idx + 1 ;
  26.          END IF;
  27.       END LOOP;
  28.    ELSE
  29.      v_sum := numValue_IN - LENGTHB(strValue_IN);
  30.      v_return := v_return||strValue_IN;
  31.      WHILE idy < v_sum LOOP
  32.         v_return := v_return||' ';
  33.         idy := idy + 1;
  34.      END LOOP;
  35.    END IF;
  36.    IF mod(lengthb(strValue_IN),2) = 0 then
  37.       v_return := v_return || ' |';
  38.    ELSE
  39.       v_return := v_return || '|';
  40.    END IF;
  41.    Return v_return;
  42. Exception
  43.   When Others Then
  44.     Zl_Errorcenter(Sqlcode, Sqlerrm);
  45. END ZL_GetSinglebyte_string;


  46. 建同义词:
  47. create or replace public synonym ZL_GetSinglebyte_string
  48. for HIS.ZL_GetSinglebyte_string;
  49. ----------------------------------------------------------
  50. GRANT EXECUTE ON ZL_GetSinglebyte_string to public

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28878983/viewspace-2133891/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-05-11

  • 博文量
    208
  • 访问量
    212338