CREATE OR REPLACE FUNCTION jgbzsmz_hebei.fn_checkidcard(p_idcard character varying)
RETURNS integer AS
$BODY$
declare
v_regstr varchar(2000);
result1 Integer;
begin
result1:=0;
if(length(p_idcard)=15 or length(p_idcard)=18) then
v_regstr:= '^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$' ;
if length(substring(p_idcard,v_regstr))>0 then
result1:=1;
end if;
v_regstr:= '^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$' ;
if length(substring(p_idcard,v_regstr))>0 then
result1:=1;
end if;
end if;
return result1;
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
postgresql实现Oracle regexp_like
最新推荐文章于 2023-12-19 17:06:50 发布