Credit Card Number Validation in PL/SQL

Billy Ma
Billy Ma used Ask the Experts™
on
I want to write a function to validation credit card number,
I found a code there
http://www.notesbit.com/index.php/scripts-oracle/validate-the-credit-card-plsql-code/
but I am not sure whether it is good or not.
Anyone can tell?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Lee WadwellProject Architect

Commented:
Hi mawingho,

not exactly how I would have written it ... but appears to follow the right rules and do the right job.

lwadwell
Billy MaVice President

Author

Commented:
So the logic is right, :) I am going to use it
Project Architect
Commented:
mawingho,

yes ... the logic for a LUHN check digit seems right.  I did test this against some data I had and it based that - it seemed to produce the right result.

references you can use are:
http://en.wikipedia.org/wiki/Luhn_algorithm
http://en.wikipedia.org/wiki/Bank_card_number

lwadwell
Naveen KumarProduction Manager / Application Support Manager

Commented:
i would say the below bit is not exactly correct. VISA card also has 16 digits right ?

.....
IF creditcardlength = 13
   THEN
      IF c1 IN (4)
      THEN
         cardtype := ‘VISA’;
......

Also if at all there is some special "," character in the card number, then we might have to put in the below extra line as well...

....
 creditcardnumber := REPLACE(creditcardnumber, '_', '');
....

I would say you test that code what all kinds of credit cards data you have in your uat /test database/environment and then take a decision accordingly after validating the test results.

Thanks
Billy MaVice President

Author

Commented:
hi nav_kum_v,
We did handle 16 digit visa card.
thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial