如何使用Oracle Forms验证NIC号码?

时间:2015-09-21 14:13:12

标签: oracle11g oracleforms

国民身份证号码如下: GL_VENDOR : Intel GL_RENDERER : Mobile Intel(R) 4 Series Express Chipset Family GL_VERSION : 2.1.0 - Build 8.15.10.1892 GL_SHADING_LANGUAGE_VERSION : 1.20 - Intel Build 8.15.10.1892

它包含9位数字,最后包含大写878552361V'V'

如何使用 Oracle Forms 11g 库验证它?

2 个答案:

答案 0 :(得分:0)

在库中编写一个函数,如下所示:

FUNCTION validate_nid (p_nid IN VARCHAR2)
   RETURN BOOLEAN
IS
   v   NUMBER;
   e EXCEPTION;
BEGIN
   IF LENGTH (p_nid) > 10
   THEN
      RAISE e;
   END IF;

   -- check if first 8 are alpa
   v := SUBSTR (p_nid, 1, 9);

   IF SUBSTR (p_nid, 10, 1) != 'V' Or
       SUBSTR (p_nid, 10, 1) != 'X'
   THEN
      RAISE e;
   END IF;

   RETURN TRUE;
EXCEPTION
   WHEN e
   THEN
      RETURN FALSE;
   WHEN OTHERS
   THEN
      RETURN FALSE;
END;

并在when-validate-item触发器中调用此函数,如下所示:

if not validate_nid('878552361V') then
  raise form_trigger_failure;
end if;

答案 1 :(得分:0)

  if (regexp_substr('876963256V','^[0-9]{9}[vV|xX]$')) is null then 
         raise form_trigger_failure;
    end if;