单字节处理函数

单字节处理函数


  • CREATE OR REPLACE Function ZL_GetSinglebyte_string
  • (
  •   strValue_IN varchar2,
  •   numValue_IN number
  • )
  • Return Varchar2 Is
  •    v_temp varchar2(200);
  •    v_return varchar2(200);
  •    v_num number:=0;
  •    v_sum number:=0;
  •    idx number :=1 ;
  •    idy number :=0 ;
  • BEGIN
  •   IF lengthb(strValue_IN)>=numValue_IN then
  •       WHILE idx <= LENGTH(strValue_IN) LOOP
  •          v_temp := SUBSTR(strValue_IN,idx,1);
  •          v_num := v_num + lengthb(v_temp);
  •          if v_num > numValue_IN then
  •             v_return := v_return||substr(strValue_IN,1,idx-1)||' ';
  •             exit;
  •          elsif v_num = numValue_IN then
  •             v_return := v_return||substr(strValue_IN,1,idx);
  •             exit;
  •          else
  •             idx := idx + 1 ;
  •          END IF;
  •       END LOOP;
  •    ELSE
  •      v_sum := numValue_IN - LENGTHB(strValue_IN);
  •      v_return := v_return||strValue_IN;
  •      WHILE idy < v_sum LOOP
  •         v_return := v_return||' ';
  •         idy := idy + 1;
  •      END LOOP;
  •    END IF;
  •    IF mod(lengthb(strValue_IN),2) = 0 then
  •       v_return := v_return || ' |';
  •    ELSE
  •       v_return := v_return || '|';
  •    END IF;
  •    Return v_return;
  • Exception
  •   When Others Then
  •     Zl_Errorcenter(Sqlcode, Sqlerrm);
  • END ZL_GetSinglebyte_string;


  • 建同义词:
  • create or replace public synonym ZL_GetSinglebyte_string
  • for HIS.ZL_GetSinglebyte_string;
  • ----------------------------------------------------------
  • GRANT EXECUTE ON ZL_GetSinglebyte_string to public