Validating idenity linksys
Regards Jan['validate-id', 'You have entered an invalid identity number', function (v) ] Hi, please can someone help with out with this problem: The second last digit in my driver's licence is DIFFERENT to that in my green ID book. Here's my code: CREATE OR REPLACE FUNCTION CS_VALID_SA_ID_NUMBER ( p_id_number IN VARCHAR2 ) RETURN BOOLEANAS lv_A NUMBER := 0; -- ~Holds Negative Index numbers lv_B NUMBER := 0; -- ~Holds Positive Index numbers lv_C NUMBER; lv_D NUMBER := -1; -- ~The check digit lv_I NUMBER; -- ~Counter Variable lv_is_valid NUMBER; lv_the_number NUMBER; lv_rply BOOLEAN := FALSE; BEGIN--Getting Negative Numbers lv_I := 0 ; IF (lv_I 0) THEN lv_C := lv_C lv_B mod 10; lv_B := lv_B / 10; END IF;lv_C := lv_C lv_A;lv_D := 10 - (lv_C mod 10); IF (lv_D = 10) THEN lv_D := 0; END IF;lv_the_number := CAST(SUBSTR(p_id_number, 13, 1) AS NUMBER); IF lv_the_number = lv_D THEN lv_is_valid := 1; lv_rply := TRUE; END IF; RETURN lv_rply; -- ************************************ -- ** Handle an unexpected exception ** -- ************************************ EXCEPTION /* When this function throws an exception outside its exception block via the exception procedure will it catch its own exception.For example, the last three digits in my driver's licence is 050 --- but in my ID it is 084This causes endless confusion. Id # to the picture and name of the person on it so I know if the person I am dealing with is legitimate or just using an valid ID # with his picture on it . I'm trying to convert Craig Peacocks SQL version to PL/SQL function and not getting anywhere. To avaoid this the following statement is required.would be interesting to see how they enforce that.... An old ex Zimbo friend of mine is a permanant resident but long time ago lost his ID book. NET post to cater for erroneous id No's like 0000000024588Its not very ellegant and wont get us into the next century, but then again neither will VB. Public Function parse Id No(By Val id No As String) As Boolean Try Dim a As Integer = 0 For i As Integer = 0 To 5 a = CInt(id No.
The only way is to use the Home Affairs link at the top of this post.
One explanation might be that that the last THREE digits indicated race group in the old days and was done away with after the ANC came to power. Thanks for any help Thanks for this link - it has given me the inspiration to clean up this blog entry - I have also added the link at the top of the text - hopefully there will be less enquiries for ID status etc. */ WHEN no_data_found THEN lv_rply := FALSE; return lv_rply; WHEN OTHERS THEN cs_raise_exception(SQLCODE, SQLERRM, 'CS_VALID_SA_ID_NUMBER'); END; OK, I've seen the errors of my ways and got it to work! Here's the Oracle PL/SQL code: CREATE OR REPLACE FUNCTION FN_VALID_SA_ID_NUMBER ( p_id_number IN VARCHAR2 ) RETURN BOOLEANAS /* ===================================================================== This function was adapted from a TSQL function written by Craig Peacock on Donal Slemon Date: 2008/08/12 Description ----------- Validates an SA ID number.
(Returns 1=valid; 0=invalid) ===================================================================== */ lv_A NUMBER := 0; -- Holds Negative Index numbers (in odd number position) lv_B VARCHAR2(7) := null; -- Holds Positive Index numbers (in even number position) lv_B_num number(8,0) := 0; -- Holds Positive Index numbers lv_C NUMBER; lv_D NUMBER := -1; -- ~The check digit variable lv_I NUMBER; -- Counter Variable lv_dob NUMBER; lv_valid_dob BOOLEAN := FALSE; lv_is_valid NUMBER; lv_last_number NUMBER; lv_rply BOOLEAN := FALSE; lv_length NUMBER; lv_length_err EXCEPTION; BEGIN-- check length not 13 THEN lv_is_valid := 0; RAISE lv_length_err ; --RETURN lv_rply; END IF;-- check if first 6 digits are valid date (not strictly speaking necessary) lv_dob := substr(p_id_number,0,6); IF lv_dob IS NOT NULL AND to_date(lv_dob,'YYMMDD') IS NOT NULL THEN lv_valid_dob := TRUE; ELSE RETURN lv_rply; END IF; lv_I := 0 ;-- adding every odd position digit (starting pos 1)(result goes into lv_A) WHILE (lv_I 0) LOOP lv_C := lv_C lv_B_num mod 10; lv_B_num := ROUND(lv_B_num / 10); END LOOP; --WHILE */-- Add answer of lv_A to answer of lv_C -- Subtract the second digit (e.g. The number must tally with the last number in the ID Number.
Probably, only the Department of Home Affairs can answer your question.
If you are looking for a test to discern the old numbers from the new numbers, this isn't it!