当前位置: 代码迷 >> 综合 >> 函数--获取字符串中的数字
  详细解决方案

函数--获取字符串中的数字

热度:5   发布时间:2024-01-21 03:23:08.0

Oracle中获取字符串中的数字:

  1. create or replace function GetNumber(str varchar2) return varchar2 IS
  2.        v_temp varchar2(200) ;
  3.        v_return varchar2(200) ;
  4.        idx number :=1 ;
  5. BEGIN
  6.      WHILE(idx <= LENGTH(str) ) LOOP
  7.      v_temp :=  SUBSTR(str,idx,1) ;
  8.          if(ASCII(UPPER(v_temp)) >= 48 AND ASCII(UPPER(v_temp)) <= 57) then 
  9.          v_return := v_return||v_temp ;
  10.      END IF ; 
  11.      idx := idx + 1 ;
  12.      END LOOP ;
  13. return v_return ;
  14. end GetNumber;
  相关解决方案