身份证号码验证自定义函数

create or replace function idcard_check

    (idcard in string) return varchar2 is

declare

 o_result varchar2(30);

begin

   if trim(idcard) regexp '^[1-9][0-9]{5}(18|19|([2][0-3]))[0-9]{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)[0-9]{3}[0-9Xx]$' or

    trim(idcard) regexp '[1-9][0-9]{5}[0-9]{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)[0-9]{3}$' then 

    o_result := trim(idcard);

           else

    o_result := '';

   end if;

    return o_result;

end;

 

posted @ 2021-04-15 09:41  Windsong的博客  阅读(200)  评论(0)    收藏  举报