1. This is a custom id check and disability of number of custom function
CREATE OR REPLACE Function Func_checkdisabilitycard (p_idcard varchar2) in Return Number
- return values: 0: wrong id number; 1: the correct id number; 2: correct deformity card number
Is
V_regstr VARCHAR2 (2000);
V_sum NUMBER;
V_mod NUMBER;
10 x98765432 v_checkcode CHAR (11) :=' ';
V_checkbit CHAR (1);
V_areacode VARCHAR2 (2000) :='11,12,13,14,15,21,22,23,31,32,33,34,35,36,37,41,42,43,44,45,46,50,51,52,53,54,61,62,63,64,65,71,81,82,91,';
The BEGIN
CASE LENGTHB (p_idcard)
15 THEN the WHEN
- 15
IF INSTRB (v_areacode, SUBSTR (p_idcard, 1, 2) | | ', ')=0 THEN
RETURN 0;
END IF;
IF the MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 2)) + 1900, 400)=0 OR
(MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 2)) + 1900, 100) & lt;> 0 AND
The MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 2)) + 1900, 4)=0) THEN
- a leap year
='^ v_regstr: [1-9] [0-9] {5} [0-9] {2} ((01 | | 07 | 3 | 05 08 | | 10 12) (0 [1-9] | [1-2] [0-9] [0, 1]) | 3 | (04 | | | 06 09 11) (0 [1-9] | [1-2] [0-9] 30) | | 02 (0 [1-9] | [1-2] [0-9])) [0-9] {3} $';
The ELSE
='^ v_regstr: [1-9] [0-9] {5} [0-9] {2} ((01 | | 07 | 3 | 05 08 | | 10 12) (0 [1-9] | [1-2] [0-9] [0, 1]) | 3 | (04 | | | 06 09 11) (0 [1-9] | [1-2] [0-9] 30) | | 02 (0 [1-9] [0-9] | 2 | 1 [0 to 8])) [0-9] {3} $';
END IF;
IF REGEXP_LIKE (p_idcard v_regstr) THEN
RETURN 1;
The ELSE
RETURN 0;
END IF;
20 THEN the WHEN
- 20
IF not regexp_like (SUBSTRB (p_idcard, 2, 2), '(^) [0-9]') then
return 0;
end if;
IF INSTRB (v_areacode, SUBSTRB (p_idcard, 1, 2) | | ', ')=0 THEN
RETURN 0;
END IF;
IF the MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 4), 400)=0 OR
(MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 4), 100) & lt;> 0 AND
The MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 4)), 4)=0) THEN
- a leap year
V_regstr:='^ (1-9] [0-9] {5} (20) 19 | [0-9] {2} ((01 | | 07 | 3 | 05 08 | | 10 12) (0 [1-9] | [1-2] [0-9] [0, 1]) | 3 | (04 | | | 06 09 11) (0 [1-9] | [1-2] [0-9] 30) | | 02 (0 [1-9] | [1-2] [0-9])) [0-9] {3} [0-9 xx] [0-9] {2} $';
The ELSE
V_regstr:='^ (1-9] [0-9] {5} (20) 19 | [0-9] {2} ((01 | | 07 | 3 | 05 08 | | 10 12) (0 [1-9] | [1-2] [0-9] [0, 1]) | 3 | (04 | | | 06 09 11) (0 [1-9] | [1-2] [0-9] 30) | | 02 (0 [1-9] [0-9] | 1 | 2-8 0)) [0-9] {3} [0-9 xx] [0-9] {2} $';
END IF;
IF REGEXP_LIKE (p_idcard v_regstr) THEN
V_sum:=(TO_NUMBER (SUBSTRB (p_idcard, 1, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 11, 1))) * 7 +
(TO_NUMBER (SUBSTRB (p_idcard, 2, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 12, 1))) * 9 +
(TO_NUMBER (SUBSTRB (p_idcard, 3, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 13, 1))) * 10 +
(TO_NUMBER (SUBSTRB (p_idcard, 4, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 14, 1))) * 5 +
(TO_NUMBER (SUBSTRB (p_idcard, 5, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 15, 1))) * 8 +
(TO_NUMBER (SUBSTRB (p_idcard, 6, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 16, 1))) * 4 +
(TO_NUMBER (SUBSTRB (p_idcard, 7, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 17, 1))) * 2 +
TO_NUMBER (SUBSTRB (p_idcard, 8, 1)) * 1 +
TO_NUMBER (SUBSTRB (p_idcard, 9, 1)) * 6 +
TO_NUMBER (SUBSTRB (p_idcard, 10, 1)) * 3;
V_mod:=MOD (v_sum, 11);
V_checkbit:=SUBSTRB (v_checkcode v_mod + 1, 1);
IF v_checkbit=upper (substrb (p_idcard, 18, 1)) and
To_number (substr (p_idcard, 2, 1)) & gt;=1 second from bottom and - disabled number 1-7 on behalf of the disability types between
To_number (substr (p_idcard, 2, 1)) & lt;=7 and
To_number (substr (p_idcard, 1, 1)) & gt;=1 and - disabled number reciprocal first on behalf of the disability level between 1-4
To_number (substr (p_idcard, 1, 1)) & lt; 4 THEN=
RETURN 2;
The ELSE
RETURN 0;
END IF;
The ELSE
RETURN 0;
END IF;
18 THEN the WHEN
18 -
IF INSTRB (v_areacode, SUBSTRB (p_idcard, 1, 2) | | ', ')=0 THEN
RETURN 0;
END IF;
IF the MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 4), 400)=0 OR
(MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 4), 100) & lt;> 0 AND
The MOD (TO_NUMBER (SUBSTRB (p_idcard, 7, 4)), 4)=0) THEN
- a leap year
='^ v_regstr: [1-9] [0-9] {5} (20) 19 | [0-9] {2} ((01 | | 07 | 3 | 05 08 | | 10 12) (0 [1-9] | [1-2] [0-9] [0, 1]) | 3 | (04 | | | 06 09 11) (0 [1-9] | [1-2] [0-9] 30) | | 02 (0 [1-9] | [1-2] [0-9])) [0-9] {3} [xx] 0-9 $';
The ELSE
='^ v_regstr: [1-9] [0-9] {5} (20) 19 | [0-9] {2} ((01 | | 07 | 3 | 05 08 | | 10 12) (0 [1-9] | [1-2] [0-9] [0, 1]) | 3 | (04 | | | 06 09 11) (0 [1-9] | [1-2] [0-9] 30) | | 02 (0 [1-9] [0-9] | 2 | 1 [0 to 8])) [0-9] {3} [xx] 0-9 $';
END IF;
IF REGEXP_LIKE (p_idcard v_regstr) THEN
V_sum:=(TO_NUMBER (SUBSTRB (p_idcard, 1, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 11, 1))) * 7 +
(TO_NUMBER (SUBSTRB (p_idcard, 2, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 12, 1))) * 9 +
(TO_NUMBER (SUBSTRB (p_idcard, 3, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 13, 1))) * 10 +
(TO_NUMBER (SUBSTRB (p_idcard, 4, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 14, 1))) * 5 +
(TO_NUMBER (SUBSTRB (p_idcard, 5, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 15, 1))) * 8 +
(TO_NUMBER (SUBSTRB (p_idcard, 6, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 16, 1))) * 4 +
(TO_NUMBER (SUBSTRB (p_idcard, 7, 1)) +
TO_NUMBER (SUBSTRB (p_idcard, 17, 1))) * 2 +
TO_NUMBER (SUBSTRB (p_idcard, 8, 1)) * 1 +
TO_NUMBER (SUBSTRB (p_idcard, 9, 1)) * 6 +
TO_NUMBER (SUBSTRB (p_idcard, 10, 1)) * 3;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull