Chinaunix首页 | 论坛 | 博客
  • 博客访问: 474597
  • 博文数量: 99
  • 博客积分: 3621
  • 博客等级: 中校
  • 技术积分: 1089
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-22 16:29
文章存档

2012年(21)

2011年(28)

2010年(50)

分类: Mysql/postgreSQL

2010-11-12 14:28:01

set global log_bin_trust_function_creators=1;
drop function if exists GetNum;
CREATE FUNCTION GetNum (Varstring varchar(50)) RETURNS varchar(30)
BEGIN
  DECLARE v_length INT DEFAULT 0;
  DECLARE v_Tmp varchar(50) default '';
  set v_length=CHAR_LENGTH(Varstring);
  WHILE v_length > 0 DO
 
    if (ASCII(mid(Varstring,v_length,1))>47 and ASCII(mid(Varstring,v_length,1))<58) then
 
        set v_Tmp=concat(v_Tmp,mid(Varstring,v_length,1));
    end if;
    SET v_length = v_length - 1;
  END WHILE;
    RETURN REVERSE(v_Tmp);
END;

select getnum('12倒萨3ppp3张三4覅5')

 

说明都懒得打了,全在代码里。

阅读(1638) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~